question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dots in URL lead to 404 (regression?)

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please do not ignore this template. If you do, your issue will be closed immediately.

Describe the bug

URLs with dots are leading to a 404 error instead of correctly displaying the corresponding page.

Note that it works fine with a project created with Vue CLI but it doesn’t work with a project created with @vite/create-app (both using Vue 3 with Vue Router 4).

I guess this is a regression from https://github.com/vitejs/vite/issues/130 but many things have change with Vite 2 (especially project structure) so it’s hard for me to identify why the bug reappeared (but with some guidance I’m happy to help).

Reproduction

Run projects and go to http://localhost:3000/just.a.test (or a similar URL).

System Info

  • vite version: 2.0.1 (with @vitejs/plugin-vue 1.1.4)
  • Operating System: Ubuntu 20.10
  • Node version: 15.10.0
  • Package manager (npm/yarn/pnpm) and version: Yarn 1.22.10

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:32
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
patak-devcommented, Mar 19, 2021

There was an issue created about this already here: https://github.com/vitejs/vite/issues/2245 But it was closed because of the use of a workaround with a plugin, that may also help you while this is open. Maybe there is a limitation I’m not aware of, but this looks like a bug, and the other issue was wrongly closed.

0reactions
silverwindcommented, Dec 12, 2022

The behaviour seems to be because vite assumes that if the final segment of the path contains ., the user meant to navigate to a file. This is a pretty bad assumption to take because files without . are valid too (although, uncommon) and modern SPAs generally expect all paths except static assets to be routed to index.html so client-side routing can take effect.

One solution could be to check existance in the file system, and if the file is not there, serve index.html, similar to try_files is often configured in nginx to serve prod apps. With such an mechanism, no option like https://github.com/vitejs/vite/pull/2634 is necessary as it’ll work correctly in all cases, but it will involve one additional stat call on each request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dots in URL causes 404 with ASP.NET mvc and IIS
URLs with the dot generate a 404. My routing is fine. If I pass in michaelphelps, without the dot, then everything works. If...
Read more >
url with dot causing 404 - MSDN - Microsoft
But if url is localhost/abc.def it causes 404. following is my route details public static void RegisterRoutes(RouteCollection routes) { routes.
Read more >
Enabling clean URLs cause a 404 error - Drupal Answers
I am trying to enable clean URL in a Drupal 7 website. The clean URL is supported by server, as I can see...
Read more >
How To Find Broken Links Using Cypress [With Examples]
There are umpteen reasons that result in 404 errors (or broken links/dead links); the major ones are mentioned below:.
Read more >
Trailing dots in url result in empty 404 page on IIS - Server Fault
The upshot of it is that there is an order-of-operations issue where the .NET handlers for various functions get mixed up and misdirect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found