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

Dev Server: History Mode does not work if the requested url looks like a file #11282

Closed
7 tasks done
dschmidt opened this issue Dec 9, 2022 · 2 comments
Closed
7 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@dschmidt
Copy link

dschmidt commented Dec 9, 2022

Describe the bug

Vite does not serve index.html when the url ends with a filename.
This is a problem for us, as we have routes like /preview/{filename} for which we need the index.html to be served in development.

I understand that the behavior we need can be annoying for other people, as you don't get 404 errors if you reference files incorrectly, so I would be happy with an opt-in solution.

Reproduction

https://stackblitz.com/edit/vitejs-vite-fmjl1q

Steps to reproduce

I need vite to serve index.html whenever no local file is found.

System Info

I tested using httpie

Used Package Manager

pnpm

Logs

No response

Validations

@Schoude
Copy link

Schoude commented Dec 9, 2022

The same thing happens with the preview server.
I have a Vue app with Vue router set up in history mode and every route that is not the root of the server returns 404 if one directly navigates to the URL (not via navigation from root). Even if i change the appType to 'spa' in the vite config this behavior still occurs.

You can recreate it here:

https://stackblitz.com/edit/vitejs-vite-mh4lvq

Build the app with npm run build and then start the preview server with npm run preview. Then visit the /about page directly or refresh the page when your are on the /about page.

@sapphi-red
Copy link
Member

Duplicate of #2415

@sapphi-red sapphi-red marked this as a duplicate of #2415 Dec 21, 2022
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2022
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Dec 21, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants