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

Generated index.html is the same for different requests #16467

Open
7 tasks done
DudaGod opened this issue Apr 19, 2024 · 1 comment
Open
7 tasks done

Generated index.html is the same for different requests #16467

DudaGod opened this issue Apr 19, 2024 · 1 comment

Comments

@DudaGod
Copy link

DudaGod commented Apr 19, 2024

Describe the bug

I write MRE - https://github.com/DudaGod/vite-gen-index.html-issue. In this repo I use post hook configureServer in which I call transformIndexHtml on each request. I expect that for different queries (they differ in the value of the query parameter) will be generated different index.html. But when opening two pages with different query parameters at the same time I get the same generated script that outputs the log from the first request.

Reproduction

https://github.com/DudaGod/vite-gen-index.html-issue

Steps to reproduce

  1. Install packages using npm install
  2. Run script node ./vite-run.js
  3. As a result, 2 pages with http://localhost:4444/?uuid=12345 and http://localhost:4444/?uuid=67890 urls will open. And both of them will have 12345 in the log (it is almost always reproduced with rare exceptions).

System Info

System:
  OS: macOS 13.6
  CPU: (10) arm64 Apple M1 Pro
  Memory: 529.50 MB / 32.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
  Yarn: 1.22.22 - ~/.nvm/versions/node/v18.12.1/bin/yarn
  npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  pnpm: 6.34.0 - ~/.nvm/versions/node/v18.12.1/bin/pnpm
Browsers:
  Chrome: 124.0.6367.61
  Safari: 16.6
npmPackages:
  vite: ^5.2.9 => 5.2.9

Used Package Manager

npm

Logs

No response

Validations

@DudaGod
Copy link
Author

DudaGod commented Apr 19, 2024

Looks like problem is here. Inside cleanUrl all query params are replaced to empty string. As a result all my requests cached to the same path - /.

Looks like this is expected behaviour and in my case I should modify query parameter to path, like this:
http://localhost:4444/?uuid=12345 -> http://localhost:4444/12345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant