From 85116eaa91740ed4c93159c871baaff673140106 Mon Sep 17 00:00:00 2001 From: TomasBankauskas Date: Tue, 1 Oct 2024 15:12:01 +0300 Subject: updated EdgeFunctionExplainer.astro --- src/components/EdgeFunctionExplainer.astro | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/EdgeFunctionExplainer.astro b/src/components/EdgeFunctionExplainer.astro index fb6e6ae..197730e 100644 --- a/src/components/EdgeFunctionExplainer.astro +++ b/src/components/EdgeFunctionExplainer.astro @@ -5,16 +5,14 @@ const explainer = ` This page is using a Netlify Edge Function (\`netlify/edge-functions/rewrite.js\`) to rewrite the URL based on visitor geography. ~~~js -const rewrite = async (request, context) => { +export default async (request, context) => { const path = context.geo?.country?.code === 'AU' ? '/edge/australia' : '/edge/not-australia'; - return new URL(path, request.url); + return Response.redirect(new URL(path, request.url)); }; export const config = { path: '/edge' }; - -export default rewrite; ~~~ [See more examples](https://edge-functions-examples.netlify.app) -- cgit v1.2.3