Remove 'navigateFallback' behavior from default SW config
See original GitHub issueI wanted to move my latest comments from https://github.com/facebookincubator/create-react-app/issues/2398#issuecomment-334227447 into a specific issue to discuss them separate from the larger meta-conversation around service workers in create-react-app
:
Here’s one possible change that could be made short of removing service worker generation: by default,
index.html
is used to handle all navigation requests for URLs that aren’t precached (config).This behavior is in there to support SPA-style offline usage, where users might navigate to URLs that don’t correspond to underlying HTML files. That being said, many developers don’t fall into that category.
What we could do is remove
navigateFallback
/navigateFallbackWhitelist
completely from the default configuration. Offline usage forindex.html
and any other files that exist as part of the Webpack build will still work. Offline usage for SPA-style routing will continue to work ifhash
-based routing is used (as opposed topushState
routing).The drawback is that getting offline support with
pushState
routing working would require aneject
and re-addingnavigateFallback
to the config, but at least there’s a specific place in the existing documentation for this use case, where we can clearly spell out the changes that are needed.
Given that it would break the “navigate to a random URL and expect it to work” offline experience for any SPAs that have gone through the steps to support the History API’s pushState()
, I think that if we move forward, it needs to wait until the next major release of create-react-app
.
@chee has put together https://github.com/facebookincubator/create-react-app/pull/3024 which would be sufficient in terms of a code change, but we’d need to accompany it with changes to the docs explaining how to eject
and re-enable that behavior for SPAs using the History API (which I’m happy to write).
CC: @Timer @gaearon @addyosmani for their thoughts.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top GitHub Comments
i wouldn’t have minded the burden! i love burden
but it’s now closed in favour of yours
thanks! it looks like a good move.
Fixed by https://github.com/facebookincubator/create-react-app/pull/3419.