Skip to content

Commit ec469c7

Browse files
authored
chore: cleanup headers, remove obsolete workarounds (#311)
* chore: cleanup headers, remove obsolete workarounds #301 wasn't quite finished, this does finalize the work: - ensure cross origin headers are only set on SvelteKit tutorial pages - remove obsolete workarounds for getting cross origin iframes/images/audio/video working * try this
1 parent 0f7fc57 commit ec469c7

File tree

14 files changed

+43
-36
lines changed

14 files changed

+43
-36
lines changed

apps/svelte.dev/content/blog/2019-01-31-svelte-on-the-changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Unless you hang out in our [Discord server](https://svelte.dev/chat) or follow [
1818

1919
On the podcast [Adam](https://twitter.com/adamstac), [Jerod](https://twitter.com/jerodsanto) and I talk about some of the changes and why we're making them. You can listen here or on the [podcast page](https://changelog.com/podcast/332).
2020

21-
<audio crossorigin="anonymous" data-theme="night" style="width: 100%" data-src="https://changelog.com/podcast/332/embed" src="https://cdn.changelog.com/uploads/podcast/332/the-changelog-332.mp3" preload="none" class="changelog-episode" controls></audio><p><a href="https://changelog.com/podcast/332">The Changelog 332: A UI framework without the framework</a> – Listen on <a href="https://changelog.com/">Changelog.com</a></p><script async src="//cdn.changelog.com/embed.js"></script>
21+
<audio data-theme="night" style="width: 100%" data-src="https://changelog.com/podcast/332/embed" src="https://cdn.changelog.com/uploads/podcast/332/the-changelog-332.mp3" preload="none" class="changelog-episode" controls></audio><p><a href="https://changelog.com/podcast/332">The Changelog 332: A UI framework without the framework</a> – Listen on <a href="https://changelog.com/">Changelog.com</a></p><script async src="//cdn.changelog.com/embed.js"></script>

apps/svelte.dev/content/blog/2019-04-22-svelte-3-rethinking-reactivity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To make that possible we first needed to rethink the concept at the heart of mod
2424
<div class="max">
2525
<figure style="max-width: 960px; margin: 0 auto">
2626
<div style="height: 0; padding: 0 0 57.1% 0; position: relative; margin: 0 auto;">
27-
<iframe credentialless style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/AdNJ3fydeao" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
27+
<iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/AdNJ3fydeao" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
2828
</div>
2929

3030
<figcaption>'Rethinking Reactivity' from <a href="https://www.israel.yglfconf.com/">You Gotta Love Frontend Code Camp</a></figcaption>

apps/svelte.dev/content/blog/2020-11-05-whats-the-deal-with-sveltekit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This was slightly tongue-in-cheek — as the talk explains, it's really more of
1616
<div class="max">
1717
<figure style="max-width: 960px; margin: 0 auto">
1818
<div style="height: 0; padding: 0 0 57.1% 0; position: relative; margin: 0 auto;">
19-
<iframe credentialless style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/qSfdtmcZ4d0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
19+
<iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/qSfdtmcZ4d0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
2020
</div>
2121

2222
<figcaption>'Futuristic Web Development' from <a href="https://sveltesummit.com/">Svelte Summit</a></figcaption>

apps/svelte.dev/content/blog/2022-12-14-announcing-sveltekit-1.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To get started, run `npm create svelte@latest`, and visit the [docs](https://kit
1414
<div class="max">
1515
<figure style="max-width: 960px; margin: 0 auto">
1616
<div style="height: 0; padding: 0 0 57.1% 0; position: relative; margin: 0 auto;">
17-
<iframe credentialless style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/N4BRVkQVoMc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
17+
<iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/N4BRVkQVoMc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
1818
</div>
1919

2020
<figcaption>Svelte Radio Live: the Christmas special</figcaption>

apps/svelte.dev/content/blog/2023-03-09-zero-config-type-safety.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ But what if we didn't even need the annotations? Since `load` and `data` are par
1111

1212
As of today, yes: it can.
1313

14-
<video crossorigin="anonymous" src="https://sveltejs.github.io/assets/video/zero-config-types.mp4" controls muted playsinline></video>
14+
<video src="https://sveltejs.github.io/assets/video/zero-config-types.mp4" controls muted playsinline></video>
1515

1616
If you're using VSCode, just upgrade the Svelte extension to the latest version, and you'll never have to annotate your `load` functions or `data` props again. Extensions for other editors can also use this feature, as long as they support the Language Server Protocol and TypeScript plugins. It even works with the latest version of our CLI diagnostics tool `svelte-check`!
1717

apps/svelte.dev/content/blog/2023-08-31-view-transitions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ onNavigate((navigation) => {
7474

7575
With that, every navigation that occurs will trigger a view transition. You can already see this in action – by default, the browser will crossfade between the old and new pages.
7676

77-
<video crossorigin="anonymous" src="https://sveltejs.github.io/assets/video/vt-demo-1.mp4" controls muted playsinline></video>
77+
<video src="https://sveltejs.github.io/assets/video/vt-demo-1.mp4" controls muted playsinline></video>
7878

7979
<details>
8080
<summary>How the code works</summary>
@@ -161,7 +161,7 @@ header {
161161

162162
Now, the header will not transition in and out on navigation, but the rest of the page will.
163163

164-
<video crossorigin="anonymous" src="https://sveltejs.github.io/assets/video/vt-demo-2.mp4" controls muted playsinline></video>
164+
<video src="https://sveltejs.github.io/assets/video/vt-demo-2.mp4" controls muted playsinline></video>
165165

166166
<details>
167167
<summary>Fixing the types</summary>
@@ -213,7 +213,7 @@ li[aria-current='page']::before {
213213

214214
By adding that single line, the indicator will now smoothly slide to its new position instead of jumping.
215215

216-
<video crossorigin="anonymous" src="https://sveltejs.github.io/assets/video/vt-demo-3.mp4" controls muted playsinline></video>
216+
<video src="https://sveltejs.github.io/assets/video/vt-demo-3.mp4" controls muted playsinline></video>
217217

218218
(It might be easy to miss the difference – look at the small moving triangle indicator at the top of the screen!)
219219

apps/svelte.dev/content/blog/2023-09-20-runes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Svelte 5 changes all that with _runes_, which unlock _universal, fine-grained re
3131
<div class="max">
3232
<figure style="max-width: 960px; margin: 0 auto">
3333
<div style="aspect-ratio: 1.755; position: relative; margin: 0 auto;">
34-
<iframe credentialless style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/RVnxF3j3N8U" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
34+
<iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/RVnxF3j3N8U" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
3535
</div>
3636

3737
<figcaption>Introducing runes</figcaption>

apps/svelte.dev/content/blog/2024-04-30-svelte-5-release-candidate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ You can learn more about the new features from the [preview documentation](https
3030
<div class="max">
3131
<figure style="max-width: 1040px; margin: 0 auto">
3232
<div style="aspect-ratio: 1.755; position: relative; margin: 0 auto;">
33-
<iframe credentialless style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/xCeYmdukOKI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
33+
<iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0; margin: 0;" src="https://www.youtube-nocookie.com/embed/xCeYmdukOKI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
3434
</div>
3535

3636
<figcaption>What You Can Do For Your Framework</figcaption>

apps/svelte.dev/content/examples/18-module-context/01-module-exports/+assets/AudioPlayer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<h2>{title}</h2>
3838
<p><strong>{composer}</strong> / performed by {performer}</p>
3939

40-
<audio crossorigin="anonymous" bind:this={audio} bind:paused onplay={stopOthers} controls {src}></audio>
40+
<audio bind:this={audio} bind:paused onplay={stopOthers} controls {src}></audio>
4141
</article>
4242

4343
<style>

apps/svelte.dev/src/routes/_home/Video.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
<video
8989
src="https://sveltejs.github.io/assets/svelte-origins-preview.mp4"
9090
loop
91-
crossorigin="anonymous"
9291
playsinline
9392
bind:this={video}
9493
bind:muted

apps/svelte.dev/src/routes/blog/[slug]/card.png/Card.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
</script>
66

77
<div class="card">
8-
<img
9-
crossorigin="anonymous"
10-
src="https://sveltejs.github.io/assets/artwork/svelte-machine.png"
11-
alt="Svelte Machine"
12-
/>
8+
<img src="https://sveltejs.github.io/assets/artwork/svelte-machine.png" alt="Svelte Machine" />
139

1410
<div class="text">
1511
<h1>{title}</h1>

apps/svelte.dev/vercel.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,24 @@
22
"$schema": "https://openapi.vercel.sh/vercel.json",
33
"headers": [
44
{
5-
"source": "/(.*)",
5+
"source": "/_app/immutable/workers/(.*)",
6+
"headers": [
7+
{
8+
"key": "cross-origin-opener-policy",
9+
"value": "same-origin"
10+
},
11+
{
12+
"key": "cross-origin-embedder-policy",
13+
"value": "require-corp"
14+
},
15+
{
16+
"key": "cross-origin-resource-policy",
17+
"value": "cross-origin"
18+
}
19+
]
20+
},
21+
{
22+
"source": "/tutorial/kit/(.*)",
623
"headers": [
724
{
825
"key": "cross-origin-opener-policy",

apps/svelte.dev/vite.config.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ const plugins: PluginOption[] = [
1111
{
1212
name: 'cross-origin-isolation-for-preview',
1313
configurePreviewServer: (server) => {
14-
server.middlewares.use((_, res, next) => {
15-
res.setHeader('cross-origin-opener-policy', 'same-origin');
16-
res.setHeader('cross-origin-embedder-policy', 'require-corp');
17-
res.setHeader('cross-origin-resource-policy', 'cross-origin');
14+
server.middlewares.use((req, res, next) => {
15+
if (req.url?.startsWith('/tutorial/kit')) {
16+
res.setHeader('cross-origin-opener-policy', 'same-origin');
17+
res.setHeader('cross-origin-embedder-policy', 'require-corp');
18+
res.setHeader('cross-origin-resource-policy', 'cross-origin');
19+
}
1820
next();
1921
});
2022
},
2123
configureServer: (server) => {
22-
server.middlewares.use((_, res, next) => {
23-
res.setHeader('cross-origin-opener-policy', 'same-origin');
24-
res.setHeader('cross-origin-embedder-policy', 'require-corp');
25-
res.setHeader('cross-origin-resource-policy', 'cross-origin');
24+
server.middlewares.use((req, res, next) => {
25+
if (req.url?.startsWith('/tutorial/kit')) {
26+
res.setHeader('cross-origin-opener-policy', 'same-origin');
27+
res.setHeader('cross-origin-embedder-policy', 'require-corp');
28+
res.setHeader('cross-origin-resource-policy', 'cross-origin');
29+
}
2630
next();
2731
});
2832
}

packages/repl/src/lib/workers/bundler/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,7 @@ async function get_bundle(
324324

325325
const cached_file = local_files_lookup.get(resolved);
326326
if (cached_file) {
327-
let code = cached_file.source;
328-
329-
// rather than remembering to add this attribute to every <audio>
330-
// element, and having to explain it in the exercise text, we
331-
// automate the cross-origin isolation requirement
332-
if (cached_file.type === 'svelte') {
333-
code = code.replace(/<audio/g, '<audio crossorigin="anonymous"');
334-
}
335-
336-
return code;
327+
return cached_file.source;
337328
}
338329

339330
if (!FETCH_CACHE.has(resolved)) {

0 commit comments

Comments
 (0)