Skip to content

Commit 6855d59

Browse files
fix: 404 when route has query param on dev (#65)
close #57
1 parent 1b0eb11 commit 6855d59

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/node/vite-plugin/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export function ssrServerPlugin({
3636
const appCtx = await createRoot(false, url) as (ViteReactSSGContext<true> | ViteReactSSGTanstackContext)
3737
const adapter = getAdapter(appCtx)
3838
const { app, base } = appCtx
39-
const searchParams = new URLSearchParams(url.split('?')[1])
39+
const [pathname, search] = url.split('?')
40+
const searchParams = new URLSearchParams(search)
4041

4142
if (!app && searchParams.has('_data')) {
4243
return adapter.handleLoader(req, res)
@@ -46,7 +47,7 @@ export function ssrServerPlugin({
4647
const transformedIndexHTML = (await onBeforePageRender?.(url, indexHTML, appCtx as any)) || indexHTML
4748

4849
const { appHTML, bodyAttributes, htmlAttributes, metaAttributes, styleTag }
49-
= await adapter.render(stripBase(url, base))
50+
= await adapter.render(stripBase(pathname, base))
5051

5152
metaAttributes.push(styleTag)
5253
const mods = await Promise.all(

0 commit comments

Comments
 (0)