service-worker.js: "Uncaught (in promise) TypeError: Request failed" on export with relative pathย #1441
Description
Describe the bug
If you configure the site to run at a relative sub-directory, like https://my-example-site.com/my-base-path/, per Base URLs, then run a sapper export
, when you load the page you get an error:
service-worker.js:1 Uncaught (in promise) TypeError: Request failed
... and if you look at the network requests in the browser console, you see it trying to load files at the root instead of the relative path (ex: http://localhost:5000/client/index.4a975818.js
instead of http://localhost:5000/my-base-path/client/index.4a975818.js
)
To Reproduce
npx degit "sveltejs/sapper-template#rollup" my-app
cd my-app
Then update the basepath via https://sapper.svelte.dev/docs#Base_URLs
Then run:
sapper export --basepath my-base-path
Then serve the files at __sapper__/build/export
locally then load the site.
Expected behavior
No error.
Information about your Sapper Installation:
System:
OS: Windows 10 10.0.18362
Binaries:
Node: 12.18.3
npm: 6.14.6
npmPackages:
rollup: ^2.3.4 => 2.26.5
sapper: ^0.28.0 => 0.28.1
svelte: ^3.17.3 => 3.24.1
Severity
Annoying, not a huge deal, but would appreciate help and interested if others are having the same issue.