Skip to content

Commit 861b817

Browse files
authored
Fix developers RSC route rewrites (#602)
1 parent 9bbf35d commit 861b817

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/lib/vercel-routing.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import fs from 'node:fs'
2+
import { describe, expect, it } from 'vitest'
3+
4+
type VercelConfig = {
5+
rewrites?: Array<{ source: string; destination: string }>
6+
}
7+
8+
describe('Vercel routing', () => {
9+
it('normalizes doubled /developers RSC routes at the edge', () => {
10+
const config = JSON.parse(fs.readFileSync('vercel.json', 'utf8')) as VercelConfig
11+
const rewrites = config.rewrites ?? []
12+
13+
expect(rewrites.slice(0, 4)).toEqual([
14+
{
15+
source: '/developers/RSC/R/developers.txt',
16+
destination: '/developers/RSC/R/_root.txt',
17+
},
18+
{
19+
source: '/developers/RSC/R/developers/:path(.*)',
20+
destination: '/developers/RSC/R/:path',
21+
},
22+
{
23+
source: '/RSC/R/developers.txt',
24+
destination: '/RSC/R/_root.txt',
25+
},
26+
{
27+
source: '/RSC/R/developers/:path(.*)',
28+
destination: '/RSC/R/:path',
29+
},
30+
])
31+
})
32+
})

vercel.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,22 @@
286286
}
287287
],
288288
"rewrites": [
289+
{
290+
"source": "/developers/RSC/R/developers.txt",
291+
"destination": "/developers/RSC/R/_root.txt"
292+
},
293+
{
294+
"source": "/developers/RSC/R/developers/:path(.*)",
295+
"destination": "/developers/RSC/R/:path"
296+
},
297+
{
298+
"source": "/RSC/R/developers.txt",
299+
"destination": "/RSC/R/_root.txt"
300+
},
301+
{
302+
"source": "/RSC/R/developers/:path(.*)",
303+
"destination": "/RSC/R/:path"
304+
},
289305
{
290306
"source": "/ingest/static/:path(.*)",
291307
"destination": "https://us-assets.i.posthog.com/static/:path"

0 commit comments

Comments
 (0)