-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Service worker returning index page for nonexistent route #3299
Comments
I noticed that this also happens for routes that do exist on the server. After a few hours of reading and experimenting, I've come to the conclusion that this is the intended behavior of create-react-app and this appears to be a catch all route "feature" in After removing the service worker registration, doing an However, when using development mode, the catch-all route is still enforced (even after removing the registration of the service worker) and I'm not sure if this is configurable. I've followed the user guide to use the |
Yeah the current behavior is kind of undesirable. There should be a way to handle Maybe create a feature request to support customizing the fallback url? |
cc @jeffposnick |
You're correct in all of your conclusions at #3299 (comment) The behavior you're observing can be modified while keeping service workers enabled, but only post- Balancing the benefits of offline-first navigations with the desire to avoid common pain points is being discussed at #3248 I'd imagine this issue could be closed in favor of that one. |
If anyone is looking for a non-eject solution to this until #3419 is merged, you can use react-app-rewired with this config-overrides.js. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs. |
Is this a bug report?
Not sure. Trying to determine that.
Which terms did you search for in User Guide?
service worker
Environment
Node v6.9.2
NPM v3.10.9
react-scripts 1.0.14
Mac OSX El Capitan 10.11.6
Google Chrome Version 61.0.3163.100 (Official Build) (64-bit)
Steps to Reproduce
./build
directory from my server.localhost:8080
. Observe that the "Welcome to React" page is displayed.localhost:8080/idonotexist
. Observe that the "Welcome to React" page is still displayed.Expected Behavior
I expected the
localhost:8080/idonotexist
request to be handled by the server, rather than the service worker.Actual Behavior
The service worker returns
localhost:8080/idonotexist
from the service worker. The page that is displayed is the default "Welcome to React" page.Is this the desired behavior of the service worker? My understanding of service workers is limited, so I'm trying to determine if this is a bug or simply a gap in my knowledge.
Thanks for the great tool. Keep up the good work.
Brandon
The text was updated successfully, but these errors were encountered: