-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
sw-precache config incorrectly serves favicon.ico (with index.html) #2894
Comments
/cc @jeffposnick |
Visiting http://localhost:5000/favicon.ico, by entering in that URL in a browser's location bar, triggers a navigation request. The service worker that I'm assuming that you navigated to http://localhost:5000/favicon.ico just as a way of checking whether the resource exists and was being served properly. If you'd like to do that, then you can make a non-navigation request for that URL, which will match the behavior of your browser when it requests the URL in order to display the appropriate tab icon. // Run this manually in the JS console if you want to check your server's response:
fetch('http://localhost:5000/favicon.ico').then(response => console.log(`A response with status ${response.status} was returned.`)); |
Thanks for the quick and informative reply, that made the current behavior make more sense. My original problem was that I added another page.html to public/ that the SW hijacked. To MCVE my problem I reported for favicon.ico. If the solution would have been to make the SW ignore everything from public/ (except index.html of course) it would have worked for me. However, I totally buy that there is no problem for favicon.ico so, and that multi-HTML builds are out of scope for create-react-app, so I think I will serve page.html from a subdomain to bypass the SW. (I don't want to eject because I like a clean source tree) Closing the issue since I don't except any action on your part. |
Thanks for the informative response, @jeffposnick! Will keep this in mind in the future. 😄 |
The SW will serve it as index.html (see facebook/create-react-app#2894 ) so bypass it by putting on a subdomain. To get accurate acknowledgements, use the output from licence-webpack-plugin (from the master-with-code-coverage-branch)
Beware that files in /public are redirected by service worker to index.html Means that https://webhooks.integrations.costlocker.com/favicon.ico is accessible on in anonymous window :) facebook/create-react-app#2894 (comment) facebook/create-react-app#3024 (comment)
https://fakturoid.integrations.costlocker.com/api/redirect?project=52375&billing=NEW&amount=78600 https://user-images.githubusercontent.com/7994022/30257989-ed274944-96b5-11e7-99b2-34274efd01c9.png service worker swallows requests... facebook/create-react-app#2894 (comment) facebook/create-react-app#3024 (comment)
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
I read https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app
Environment
node -v
: v6.10.3npm -v
: 4.6.1yarn --version
(if you use Yarn): Not usednpm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.10Then, specify:
Steps to Reproduce
Expected Behavior
favicon.ico is served, either by the service-worker or by serve directly
Actual Behavior
index.html is served.
(If you Shift+F5 to bypass service-worker, the correct favicon.ico is served)
Reproducible Demo
This is not a MCVE (although the step-by-step above is) but if you want to see the issue live you can visit
https://sequencediagram.io/ (to install service worker) and then https://sequencediagram.io/favicon.ico
Other info
As far as I know, favicon.ico is not a special case in service workers i.e. a proper service worker should handle favicon.ico properly.
Btw, thanks for create-react-app, it is awesome!
The text was updated successfully, but these errors were encountered: