Repository navigation
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/6b93b41f79c346bc0f3f779ab897bb1ad82f20b1Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: 6b93b41 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
kdelay
left a comment
There was a problem hiding this comment.
Side effect worth noting: with crossorigin on the SSR stylesheet link, a cross-origin paths.assets must send Access-Control-Allow-Origin for CSS on initial load too.
CSR pages already need that, since the JS chunks are module scripts from the same origin. A csr = false page has none, so its CSS loads today from a bucket with no CORS config and would be blocked after this.
Probably fine, but worth a line in the changeset and the paths.assets docs (which don't mention CORS) so people know to add the header.
|
@kdelay Thanks for your review. Right now a |
closes #17403
SvelteKit renders
<link rel="stylesheet">and therel="preload"; as="style"Link header withoutcrossorigin. Vite's preload helper and SvelteKit's ownload_cssrequest the same stylesheets withcrossorigin. Ifpaths.assetsis on another origin and its server sends CORS headers only for requests with anOriginheader, the browser can reuse the cached no-cors response for the CORS request and block the stylesheet. The issue has a reproduction.This PR adds
crossoriginto both. Without it on the Link header, the browser fetches the preload in no-cors mode and reuses that response for the<link crossorigin>, so the CSS fails on a full page load.Tests:
test/apps/optionschecks the SSR stylesheet links with a cross-originpaths.assets, andtest/apps/options-2checks theLinkheader withlinkHeaderPreload. Both fail without the change.After an upgrade, browsers reuse stylesheets cached by the previous version (without
Access-Control-Allow-Origin) for the new<link crossorigin>until the file names change. Vite changed all CSS hashes once to handle this (vitejs/vite#18367). Should this PR do the same?AI disclosure: Claude helped with the investigation, drafted this change and the tests, and helped with the English. I reviewed and tested everything myself.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits