Skip to content

Commit 0da6ea7

Browse files
committed
chore: handle crawler bots with edge functions
1 parent 2b466c4 commit 0da6ea7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Config } from '@netlify/edge-functions'
2+
3+
export default async function () {
4+
const html404
5+
= '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>404 Not Found</h1></body></html>'
6+
7+
return new Response(html404, {
8+
status: 404,
9+
headers: {
10+
'Content-Type': 'text/html',
11+
'netlify-cdn-cache-control':
12+
'durable, immutable, max-age=31536000, public',
13+
},
14+
})
15+
}
16+
17+
export const config: Config = {
18+
cache: 'manual',
19+
pattern: '^.*\\.[Pp][Hh][Pp]$',
20+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@changesets/cli": "^2.27.8",
2020
"@clerk/clerk-sdk-node": "^5.0.46",
2121
"@clerk/themes": "^2.1.33",
22+
"@netlify/edge-functions": "^2.11.0",
2223
"@netlify/functions": "^2.8.2",
2324
"@netlify/integrations": "^0.5.4",
2425
"@netlify/sentry": "^0.0.10",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)