hugo-book icon indicating copy to clipboard operation
hugo-book copied to clipboard

Question: ServiceWorker max scope settings problem

Open hitzhangjie opened this issue 2 years ago • 1 comments

Hi, please help me about the service worker sw.js/sw-register.js scope relevant settings.

My problem is reproduced like this:

  • I use hitzhangjie.github.io as my github pages service
  • And I have written a book gogogo, I published to hitzhangjie.github.io/gogogo
  • When I local development mode, I run hugo serve

Here, I changed the settings of the path of facicon.png, facicon.svg, and markdown render-image in .

It reports the error like this:

The path of the provided scope ('/') is not under the max scope allowed ('/go-internals-v2/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.

Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('http://localhost:1313/') with script ('http://localhost:1313/go-internals-v2/sw.js'): The path of the provided scope ('/') is not under the max scope allowed ('/go-internals-v2/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.

I only see a assets/manifest.json file which may be relevant to this problem. But I don't know what it means and how to work it around. I see a setting to disable the service worker in config.toml. It works. But I want to enable it.

Please help :)

hitzhangjie avatar Jul 19 '22 05:07 hitzhangjie

Hi! When you build your website, what baseURL you specify? it needs to be hitzhangjie.github.io/gogogo/go-internals-v2/ for relative URLs to work (If I understand you folder layout correct)

alex-shpak avatar Jul 19 '22 15:07 alex-shpak