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

Service Worker: try to access to a static file always refer to 'index.html'? #3975

Closed
littlee opened this issue Feb 5, 2018 · 6 comments
Closed

Comments

@littlee
Copy link

littlee commented Feb 5, 2018

Is this a bug report?

Maybe yes

I put a image file in /public/ as /public/images/share.png, and in production, when I try to access this image in browser (by putting in address in address bar) with 'https://mydomain/images/share.png', the browser always open the main page (/public/index.html).

And I update my Chrome to latest version, nothing changed.

And when I access 'https://mydomain/images/share.png', and press crtl+shift+R, it works normally, but if I use the refresh button or press ctrl + R, it open /public/index.html again

After unregistering the service worker, everything works fine.

Is this how service worker works ?

@gaearon
Copy link
Contributor

gaearon commented Feb 9, 2018

cc @jeffposnick

@jeffposnick
Copy link
Contributor

This is a duplicate of

and others. It's the expected behavior "as of right now", and there's background info in those bugs and in the docs.

Given the developer confusion, we were initially going to address this by keeping the service worker registered, but removing that specific behavior of "falling back" to index.html for navigations (#3248).

But, the decision was made to disable service worker registration by default in the next branch of c-r-a. Given that developers who do choose to opt-in to using service workers are more likely to actually want this behavior, there's a PR out (#3924) to re-add it to next, but only if the developer opt-in to service worker registration.

@spawnia
Copy link

spawnia commented May 7, 2018

This caused me to spend 2 hours digging through nginx config, which was quite the learning experience but also absolutely infuriating.

@haywirez
Copy link

haywirez commented Jul 4, 2018

@spawnia can you share your learnings? I'm afraid I'm in the same boat. what is to be done?

@spawnia
Copy link

spawnia commented Jul 4, 2018

I put my static files in the public folder and i switched to "react-scripts": "^2.0.0-next.66cc7a90"

@stale
Copy link

stale bot commented Nov 2, 2018

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.

@stale stale bot added the stale label Nov 2, 2018
@Timer Timer closed this as completed Nov 2, 2018
@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants