mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 21:32:51 +00:00
[og] Route crawlers via middleware, not a rewrite
The OG function deployed and worked (`/api/og?v=<nevent>` returns the real title, description, thumbnail and player card), but crawlers hitting `/?v=<nevent>` still got the site-wide card: Vercel evaluates `rewrites` AFTER the filesystem, and `/` matches the static index.html, so the rewrite never fired. Middleware runs before the filesystem check, so that is where the routing belongs. Replace the dead `rewrites` block with a root middleware that matches only `/`, bails immediately when there is no `v` param or the user-agent is not a known preview crawler, and otherwise rewrites to /api/og. Real viewers are unaffected -- they fall through to the untouched SPA. Note the one behavioral difference from the rewrite design: middleware now executes on homepage requests (matcher is `/` only) rather than being invoked solely for crawlers. It returns next() after two cheap checks. Verified on the live unstable deployment that /api/og already renders `x-bitvid-og: video` with og:type video.other for the real note; this only fixes how crawlers reach it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
e5784893a8
commit
04075ff56b
4 files changed
+63
-17
No files matched your search
Generated
+7
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.7.4",
|
||||
"@tailwindcss/typography": "^0.5.19",
|
||||
"@vercel/edge": "^1.3.1",
|
||||
"autoprefixer": "^10.4.24",
|
||||
"cross-env": "^10.1.0",
|
||||
"esbuild": "^0.27.3",
|
||||
@@ -1478,6 +1479,12 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@vercel/edge": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/edge/-/edge-1.3.1.tgz",
|
||||
"integrity": "sha512-k0tKWeYEWOv6qU6+Z8+hv2Nt/u3vFHRZdB0uvwE0DxoddU/5kWX/Chu8F6ojvqmRlnZwuX/7kyZFVeCP6DxqBg==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@vitest/expect": {
|
||||
"version": "4.0.18",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.18.tgz",
|
||||
|
||||
Reference in new issue
Block a user