Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question mark at the end of a route causes precached route to not match #3291

Open
MoritzLost opened this issue Jan 26, 2024 · 0 comments
Open

Comments

@MoritzLost
Copy link

MoritzLost commented Jan 26, 2024

I'm seeing an issue where navigating to a precached route (using workbox.precacheAndRoute()) will fail and display the navigateFallback if there is a single ? without any URL parameters at the end.

That is, navigating to /some/page will work, but navigating to /some/page? will show the 404 page (navigateFallback).

I found that setting ignoreURLParametersMatching to [/.*/] (i.e. ignore all URL parameters) solves this issue. However, this is awkward. There are no actual URL parameters here, so the only way to match this case is to ignore all URL parameters. It's impossible to only match this case (? without any parameters), but not match actual parameters, or only match some parameters as far as I can tell.

Edit: Actually, looks like setting this option doesn't work at all, I'm still getting a 404 page.

Library Affected:

  • workbox-precaching, workbox-build

Browser & Platform:

All browsers

Issue or Feature Request Description:

Arguably, an empty query (only a ? at the end of the URL with nothing else) should match precached pages by default. If this isn't possible or there's some edge-case I'm not seeing, it should be possible to configure ignoreURLParametersMatching in a way that allows this case to match the precached route, but not other URL parameters.

I'm using generateSW right now. Happy to switch to injectManifest to address this. Looks like urlManipulation is the option I'm looking for? As far as I can tell this isn't available with generateSW. Still, the default behavior could be improved here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant