sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
7k stars 434 forks source link

Sapper + GitHub Pages: allow to access a route from the application menus, but fails when accessing via URL #1718

Closed silvioprog closed 3 years ago

silvioprog commented 3 years ago

Hi.

I have the following Sapper application hosted on GitHub Pages:

https://comprasonline.app.br

When you use its menus from the left bar, you can access their respective routes (sub pages) properly, but, if you copy the URL from your browser, open a new tab and try to access it directly, a 404 error is returned.

The GIF below shows the problem step by step:

screen-capture

I have been trying to solve it, but I don't know any criteria to search regarding this problem, so I don't know if it is any bug in Sapper, or just any configuration in my application. 😕

TIA for any help!

Conduitry commented 3 years ago

If you're pushing an exported app to GH pages, you need to make sure that all pages are crawlable via their static HTML. Alternatively, you can create a catch-all 404 page that redirects back to the main page with the path in a query parameter. Search online for how to create a single page app in GitHub pages.