mefechoel / svelte-navigator

Simple, accessible routing for Svelte
Other
502 stars 39 forks source link

Page refresh is not working #31

Closed codixir closed 3 years ago

codixir commented 3 years ago

I am trying to build a simple client-side svelte app with firebase (firestore and firebase auth) as a backend. I am getting a page with (This page cannot be found message) every time I try to do browser refresh/reload.

mefechoel commented 3 years ago

Yes, I suspect you need to configure how you page is served. What happens is the following: you go to lets say mypage.com. You click a link and the url changes to mypage.com/profile or wherever the link goes. But since the app is a single page app, the Router prevents the browser from making a request to /profile. Instead it just renders the component you've given to your profile route. The error happens when you reload the page. Now the browser does send a request to /profile but since your backen presumably only has an index.html file you get back a 404. To work around that you need to tell ypur backend to always serve the index.html file whenever it does not know what to do with a request. I've never worked with firebase, but I'm sure you can configure it to work with single page apps. A search for something like "setup firebase for spa" should give you something to work with.

mefechoel commented 3 years ago

I found this page on hosting in the firebase docs which might help.

codixir commented 3 years ago

I found this page on hosting in the firebase docs which might help.

thank you