@@ -29,6 +29,8 @@ interface CreateRscRequestHandlerOptions {
29
29
viteDevServer ?: ViteDevServer
30
30
}
31
31
32
+ const BASE_PATH = '/rw-rsc/'
33
+
32
34
export function createRscRequestHandler (
33
35
options : CreateRscRequestHandlerOptions ,
34
36
) {
@@ -39,9 +41,7 @@ export function createRscRequestHandler(
39
41
res : ExpressResponse ,
40
42
next : ( ) => void ,
41
43
) => {
42
- const basePath = '/rw-rsc/'
43
-
44
- console . log ( 'basePath' , basePath )
44
+ console . log ( 'BASE_PATH' , BASE_PATH )
45
45
console . log ( 'req.originalUrl' , req . originalUrl , 'req.url' , req . url )
46
46
console . log ( 'req.headers.host' , req . headers . host )
47
47
console . log ( "req.headers['rw-rsc']" , req . headers [ 'rw-rsc' ] )
@@ -97,7 +97,7 @@ export function createRscRequestHandler(
97
97
let rsaId : string | undefined
98
98
let args : unknown [ ] = [ ]
99
99
100
- if ( url . pathname . startsWith ( basePath ) ) {
100
+ if ( url . pathname . startsWith ( BASE_PATH ) ) {
101
101
rscId = url . pathname . split ( '/' ) . pop ( )
102
102
rsaId = url . searchParams . get ( 'action_id' ) || undefined
103
103
@@ -124,8 +124,6 @@ export function createRscRequestHandler(
124
124
args = await reply
125
125
126
126
// 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)
129
127
if ( args [ 0 ] instanceof FormData ) {
130
128
const serializedFormData : Record < string , any > = { }
131
129
@@ -212,7 +210,7 @@ export function createRscRequestHandler(
212
210
props,
213
211
rsaId,
214
212
args,
215
- basePath,
213
+ basePath : BASE_PATH ,
216
214
req,
217
215
handleError,
218
216
} )
0 commit comments