sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
7k stars 434 forks source link

`sapper export` on Vercel/Netlify failed to use clients/*.js scripts because the request credentials mode does not match #1727

Closed johannchopin closed 3 years ago

johannchopin commented 3 years ago

Hi team 👋 First of all thanks for your work this tool is really amazing 👍 I tried a lot to find a solution to this problem by my own but didn't find any ressource online.

Describe the bug I created a little documentation website with sapper that works perfectly fine locally in the export mode (sapper export --legacy && npx serve __sapper__/export). Then I served the files from __sapper__/export on vercel. It work fine on first load but if I reload the page, I get curious warning in the terminal:

client.21225cac.js:1 A preload for 'https://restapify.vercel.app/client/index.4c8e2a18.js' is found, but is not used because the request credentials mode does not match. Consider taking a look at crossorigin attribute.

It wouldn't be too much of a problem if it was only warnings, but unfortunately it seems that js scrips are not used and cause errors. For example if I see these warnings and I click on a link to another page I get this error:

client.21225cac.js:1 Uncaught (in promise) TypeError: Cannot read property 'parentNode' of undefined at p (client.21225cac.js:1)

To Reproduce Unfortunately I have not been able to reproduce the bug with the sapper template. You can still see the warnings on the website https://restapify.vercel.app.

Expected behavior Don't have warnings for crossorigin attribute and no runtime crash

Information about your Sapper Installation:

System: OS: macOS 11.1 CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 998.84 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.4 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.10 - /usr/local/bin/npm Browsers: Brave Browser: 83.1.10.97 Chrome: 88.0.4324.192 Edge: 88.0.705.74 Firefox: 82.0.3 Safari: 14.0.2 npmPackages: rollup: ^2.3.4 => 2.39.1 sapper: ^0.28.0 => 0.28.10 svelte: ^3.17.3 => 3.32.3

Severity It is blocking all user that want to access the static hosted website on Vercel.

EDIT:

I tried to also deploy it on netlify and it give me same issue 😢

cfey commented 3 years ago

Hi, I'm not able to reproduce your issue, I don't see any warning on your site. Even after refreshing the site.

johannchopin commented 3 years ago

Ouups really sorry I updated it by using the vercel-sapper builder. So this issue is outdated with the example of http://restapify.vercel.app/. Sorry for not updating this issue before.