Skip to content

Commit

Permalink
chore: handle crawler bots with edge functions
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerzl committed Oct 7, 2024
1 parent 2b466c4 commit 0da6ea7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions netlify/edge-functions/handle-crawler-bots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Config } from '@netlify/edge-functions'

export default async function () {
const html404
= '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>404 Not Found</h1></body></html>'

return new Response(html404, {
status: 404,
headers: {
'Content-Type': 'text/html',
'netlify-cdn-cache-control':
'durable, immutable, max-age=31536000, public',
},
})
}

export const config: Config = {
cache: 'manual',
pattern: '^.*\\.[Pp][Hh][Pp]$',
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@changesets/cli": "^2.27.8",
"@clerk/clerk-sdk-node": "^5.0.46",
"@clerk/themes": "^2.1.33",
"@netlify/edge-functions": "^2.11.0",
"@netlify/functions": "^2.8.2",
"@netlify/integrations": "^0.5.4",
"@netlify/sentry": "^0.0.10",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0da6ea7

Please sign in to comment.