AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
669 stars 30 forks source link

Using subpage in a Svelte+Vite project causes 404 #66

Closed chaosprint closed 3 years ago

chaosprint commented 3 years ago

I have read the docs:

Server side setup for History API method When you use the History API and point the browser to the root path / (usually /index.html) all links and Routes will work properly. But when you start your app on any subpage, like /page/subpage, you will see the 404 Not found error. Because of this, you need to setup your server to point all requests to /index.html.

This is easy if you use the official Svelte template. Just open package.json and find this NPM script:

"start": "sirv public"

Replace it with this line:

"start": "sirv public --single"

Now, start your app with npm run dev and open a URL like http://localhost:5000/page/subpage. You should see the app page, instead of the "Not found" error.

For other servers you can read the following links: Nginx, Apache, Caddy

But how should I solve it with Vite?

AlexxNB commented 3 years ago

I think, better place to find answer is Vite's github or website.