Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite ssr - spaces in url leads to different req.pathname #9446

Closed
7 tasks done
mkilpatrick opened this issue Jul 29, 2022 · 5 comments · Fixed by #13581
Closed
7 tasks done

vite ssr - spaces in url leads to different req.pathname #9446

mkilpatrick opened this issue Jul 29, 2022 · 5 comments · Fixed by #13581
Labels
feat: ssr p2-edge-case Bug, but has workaround or limited in scope (priority)

Comments

@mkilpatrick
Copy link

Describe the bug

Making a request in SSR mode to http://localhost:5173/indextest/dangiel1 leads to the req.originalUrl looking like
/indextest/dangiel1
but making a request to http://localhost:5173/index%20test/dangiel1 (note the %20 space) leads to:
/@id/__x00__/index%20test/dangiel1

Reproduction

N/A

System Info

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Max
    Memory: 954.67 MB / 64.00 GB
    Shell: 5.1.16 - /usr/local/bin/bash
  Binaries:
    Node: 17.9.0 - ~/.nvm/versions/node/v17.9.0/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v17.9.0/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v17.9.0/bin/npm
  Browsers:
    Chrome: 103.0.5060.134
    Safari: 15.5

Used Package Manager

npm

Logs

No response

Validations

@mkilpatrick
Copy link
Author

It's worth noting that my route handling is set up to handle a special root page:

  app.use(
    /^\/(.+)/,
    serverRenderRoute({ vite })
  );

  // Serve the index page at the root of the dev server.
  app.use(
    "/",
    indexPage()
  );

@github-actions
Copy link

github-actions bot commented Aug 1, 2022

Hello @mkilpatrick. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@sapphi-red
Copy link
Member

It doesn't reproduce with a simple setup. Please provide a reproduction.
https://stackblitz.com/edit/github-rfwq5p?file=src%2Fentry-server.js,server.js

@mkilpatrick
Copy link
Author

Here's a reproduction - https://github.com/mkilpatrick/vite-ssr-react-base/tree/url-space. Start up the server and go to http://localhost:5173/about vs http://localhost:5173/about%20me.

It's related to inline modules and SSR.

[vite] Internal server error: Cannot read properties of undefined (reading '0')
      at Context.load (file:///Users/mkilpatrick/Desktop/vite-ssr-react-base/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:41067:65)
      at Object.load (file:///Users/mkilpatrick/Desktop/vite-ssr-react-base/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:35260:50)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async loadAndTransform (file:///Users/mkilpatrick/Desktop/vite-ssr-react-base/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:39751:24) (x3)
/@id/__x00__/about%20me?html-proxy&index=0.js
No routes matched location "/@id/__x00__/about%20me?html-proxy&index=0.js"

It's happening in the vite:html-inline-proxy load code.

@sapphi-red sapphi-red added feat: ssr p2-edge-case Bug, but has workaround or limited in scope (priority) and removed needs reproduction labels Aug 2, 2022
@sapphi-red
Copy link
Member

It seems there is an inconsistency of filePath.

// HTML Proxy Caches are stored by config -> filePath -> index
export const htmlProxyMap = new WeakMap<
ResolvedConfig,
Map<string, Array<{ code: string; map?: SourceMapInput }>>
>()

It reproduces with #9054 (comment), too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: ssr p2-edge-case Bug, but has workaround or limited in scope (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants