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

wrong ServiceWorker script path when using prefix #195

Closed
panlina opened this issue Sep 28, 2018 · 2 comments
Closed

wrong ServiceWorker script path when using prefix #195

panlina opened this issue Sep 28, 2018 · 2 comments
Labels

Comments

@panlina
Copy link

panlina commented Sep 28, 2018

Hi,
I'm using cloudcmd behind a proxy, so I set prefix to "/cloudcmd", then I found that the browser console gave an error saying:

Failed to register a ServiceWorker: The origin of the provided scriptURL ('https://cloudcmd') does not match the current origin

Digging into the source I found this line of code:

prefix = prefix ? `/${prefix}/` : `/`;

From example code in this repo I believe prefix is supposed to contain the leading slash(/). If that's true, prefix will become "//cloudcmd/" and the script path to register will become "//cloudcmd/sw.js":

return navigator.serviceWorker.register(`${prefix}sw.js`);

That's exactly how the 'https://cloudcmd' in the error message comes in. Obviously the intended path is "/cloudcmd/sw.js", so I believe `/${prefix}/` should be `${prefix}/`.
Am I right?

@coderaiser
Copy link
Owner

Yes you right, thank you :), fixed with b5f9261, landed in v11.2.2 🎉

@panlina
Copy link
Author

panlina commented Sep 29, 2018

It's fixed. Thanks for your quick fix. 😄

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

No branches or pull requests

2 participants