Skip to content

Commit

Permalink
rscRequestHandler.ts: Make BASE_PATH naming match client.ts (#11401)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Aug 30, 2024
1 parent 327ffc2 commit 9228a5a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/vite/src/rsc/rscRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ interface CreateRscRequestHandlerOptions {
viteDevServer?: ViteDevServer
}

const BASE_PATH = '/rw-rsc/'

export function createRscRequestHandler(
options: CreateRscRequestHandlerOptions,
) {
Expand All @@ -39,9 +41,7 @@ export function createRscRequestHandler(
res: ExpressResponse,
next: () => void,
) => {
const basePath = '/rw-rsc/'

console.log('basePath', basePath)
console.log('BASE_PATH', BASE_PATH)
console.log('req.originalUrl', req.originalUrl, 'req.url', req.url)
console.log('req.headers.host', req.headers.host)
console.log("req.headers['rw-rsc']", req.headers['rw-rsc'])
Expand Down Expand Up @@ -97,7 +97,7 @@ export function createRscRequestHandler(
let rsaId: string | undefined
let args: unknown[] = []

if (url.pathname.startsWith(basePath)) {
if (url.pathname.startsWith(BASE_PATH)) {
rscId = url.pathname.split('/').pop()
rsaId = url.searchParams.get('action_id') || undefined

Expand All @@ -124,8 +124,6 @@ export function createRscRequestHandler(
args = await reply

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

Expand Down Expand Up @@ -212,7 +210,7 @@ export function createRscRequestHandler(
props,
rsaId,
args,
basePath,
basePath: BASE_PATH,
req,
handleError,
})
Expand Down

0 comments on commit 9228a5a

Please sign in to comment.