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

Dots in URL lead to 404 instead of index.html served #130

Closed
sventschui opened this issue May 12, 2020 · 1 comment
Closed

Dots in URL lead to 404 instead of index.html served #130

sventschui opened this issue May 12, 2020 · 1 comment

Comments

@sventschui
Copy link
Contributor

Describe the bug

When adding dots to the URL (i.e. /tag/10.4.1) vite returns a 404 instead of index.html

Reproduction

n/a

System Info

  • required vite version: 0.14.2
  • required Operating System: OS X
  • required Node version: 13.12.0

Logs (Optional if provided reproduction)

no logs, just a 404

@sventschui sventschui added the bug label May 12, 2020
@sventschui
Copy link
Contributor Author

sventschui commented May 13, 2020

So the problem is the following line: https://github.com/vuejs/vite/blob/master/src/node/server/serverPluginServeStatic.ts#L30

It prevents everything with a dot inside being redirected to index.html.

When dropping it, it happens that all JS files are redirected to index.html. This is due to await next() being called in all plugins even if they already "handled" the request. Is this intentional?

I'd suggest to:

  • Adjust server plugins to only call next() when the request was not handled
  • Use ctx.path instead of removing query and hash from ctx.url in serverPluginServeStatic.ts
  • Adjust the check for relative paths to ctx.path !== path.resolve(ctx.path)

Would you agree on this? If so I'll file a PR

EDIT: What is even the reason to check for relative paths, I do not yet get this?

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

No branches or pull requests

1 participant