Skip to content

Commit 9228a5a

Browse files
authored
rscRequestHandler.ts: Make BASE_PATH naming match client.ts (#11401)
1 parent 327ffc2 commit 9228a5a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

packages/vite/src/rsc/rscRequestHandler.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ interface CreateRscRequestHandlerOptions {
2929
viteDevServer?: ViteDevServer
3030
}
3131

32+
const BASE_PATH = '/rw-rsc/'
33+
3234
export function createRscRequestHandler(
3335
options: CreateRscRequestHandlerOptions,
3436
) {
@@ -39,9 +41,7 @@ export function createRscRequestHandler(
3941
res: ExpressResponse,
4042
next: () => void,
4143
) => {
42-
const basePath = '/rw-rsc/'
43-
44-
console.log('basePath', basePath)
44+
console.log('BASE_PATH', BASE_PATH)
4545
console.log('req.originalUrl', req.originalUrl, 'req.url', req.url)
4646
console.log('req.headers.host', req.headers.host)
4747
console.log("req.headers['rw-rsc']", req.headers['rw-rsc'])
@@ -97,7 +97,7 @@ export function createRscRequestHandler(
9797
let rsaId: string | undefined
9898
let args: unknown[] = []
9999

100-
if (url.pathname.startsWith(basePath)) {
100+
if (url.pathname.startsWith(BASE_PATH)) {
101101
rscId = url.pathname.split('/').pop()
102102
rsaId = url.searchParams.get('action_id') || undefined
103103

@@ -124,8 +124,6 @@ export function createRscRequestHandler(
124124
args = await reply
125125

126126
// TODO (RSC): Loop over args (to not only look at args[0])
127-
// TODO (RSC): Verify that this works with node16 (MDN says FormData is
128-
// only supported in node18 and up)
129127
if (args[0] instanceof FormData) {
130128
const serializedFormData: Record<string, any> = {}
131129

@@ -212,7 +210,7 @@ export function createRscRequestHandler(
212210
props,
213211
rsaId,
214212
args,
215-
basePath,
213+
basePath: BASE_PATH,
216214
req,
217215
handleError,
218216
})

0 commit comments

Comments
 (0)