@@ -6,7 +6,8 @@ import browserslist from 'browserslist';
66
77const plugins : PluginOption [ ] = [
88 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
1011 {
1112 name : 'cross-origin-isolation-for-preview' ,
1213 configurePreviewServer : ( server ) => {
@@ -16,6 +17,14 @@ const plugins: PluginOption[] = [
1617 res . setHeader ( 'cross-origin-resource-policy' , 'cross-origin' ) ;
1718 next ( ) ;
1819 } ) ;
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+ } ) ;
1928 }
2029 } ,
2130 sveltekit ( ) as PluginOption
@@ -50,7 +59,7 @@ const config: UserConfig = {
5059 } ,
5160 server : {
5261 fs : { allow : [ '../../packages' , '../../../KIT/kit/packages/kit' ] } ,
53- // for tutorial
62+ // for SvelteKit tutorial
5463 headers : {
5564 'cross-origin-opener-policy' : 'same-origin' ,
5665 'cross-origin-embedder-policy' : 'require-corp' ,
0 commit comments