summaryrefslogtreecommitdiff
path: root/src/components/EdgeFunctionExplainer.astro
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/EdgeFunctionExplainer.astro')
-rw-r--r--src/components/EdgeFunctionExplainer.astro6
1 files 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)