summaryrefslogtreecommitdiff
path: root/src/components/EdgeFunctionExplainer.astro
blob: 197730e4e6955da97d70e6134c5f9c60568da749 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---
import Markdown from './Markdown.astro';

const explainer = `
This page is using a Netlify Edge Function (\`netlify/edge-functions/rewrite.js\`) to rewrite the URL based on visitor geography.

~~~js
export default async (request, context) => {
    const path = context.geo?.country?.code === 'AU' ? '/edge/australia' : '/edge/not-australia';
    return Response.redirect(new URL(path, request.url));
};

export const config = {
    path: '/edge'
};
~~~

[See more examples](https://edge-functions-examples.netlify.app)
`;
---

<Markdown content={explainer} />