summaryrefslogtreecommitdiff
path: root/src/components/EdgeFunctionExplainer.astro
blob: fb6e6aef1267c3c807e2a29e75e27482ec618b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
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
const rewrite = async (request, context) => {
    const path = context.geo?.country?.code === 'AU' ? '/edge/australia' : '/edge/not-australia';
    return new URL(path, request.url);
};

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

export default rewrite;
~~~

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

<Markdown content={explainer} />