sveltekit icon indicating copy to clipboard operation
sveltekit copied to clipboard

Example project renders home page on missing routes

Open kelvindecosta opened this issue 1 year ago • 5 comments

Overview

When navigating to missing routes (404) within the example project, the home page (/) is rendered instead.

I've adopted almost the same configuration and service worker script for a personal project. I've noticed that the service worker even redirects server routes (+server.ts) to /.

Cause

I think that the issue lies within the following lines within the service worker script:

https://github.com/vite-pwa/sveltekit/blob/c6c34992a1cd5cec2bb58ea1ae82273c9308048c/examples/sveltekit-ts/src/prompt-sw.ts#L21-L29

When getting rid of these lines from my personal project, I no longer run into this issue.

  • Missing routes render the default 404 error page
  • +server.ts routes behave as expected

Note

I've also run a Lighthouse test to check that the PWA functionality isn't compromised. When previewing locally, when offline, the service worker performs as expected.

Conclusion

I would appreciate it if some more context could be added as to why these lines are required.

Thank you for your time.

kelvindecosta avatar Apr 26 '23 09:04 kelvindecosta