@@ -6,7 +6,8 @@ import browserslist from 'browserslist';
6
6
7
7
const plugins : PluginOption [ ] = [
8
8
enhancedImages ( ) ,
9
- // apply cross-origin isolation headers for tutorial when previewing locally
9
+ // apply cross-origin isolation headers for tutorial when developing/previewing locally,
10
+ // else web containers don't work and images don't load in the rollup iframe
10
11
{
11
12
name : 'cross-origin-isolation-for-preview' ,
12
13
configurePreviewServer : ( server ) => {
@@ -16,6 +17,14 @@ const plugins: PluginOption[] = [
16
17
res . setHeader ( 'cross-origin-resource-policy' , 'cross-origin' ) ;
17
18
next ( ) ;
18
19
} ) ;
20
+ } ,
21
+ 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' ) ;
26
+ next ( ) ;
27
+ } ) ;
19
28
}
20
29
} ,
21
30
sveltekit ( ) as PluginOption
@@ -50,7 +59,7 @@ const config: UserConfig = {
50
59
} ,
51
60
server : {
52
61
fs : { allow : [ '../../packages' , '../../../KIT/kit/packages/kit' ] } ,
53
- // for tutorial
62
+ // for SvelteKit tutorial
54
63
headers : {
55
64
'cross-origin-opener-policy' : 'same-origin' ,
56
65
'cross-origin-embedder-policy' : 'require-corp' ,
0 commit comments