File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
packages/pwa-kit-runtime/src/ssr/server Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -911,8 +911,24 @@ export const RemoteServerFactory = {
911911
912912 const content = fs . readFileSync ( workerFilePath , { encoding : 'utf8' } )
913913
914+ // If the service worker is not updated when content security policy headers inside
915+ // ssr.js are changed, then service worker initiated requests will continue to use
916+ // the old CSP headers.
917+ //
918+ // This is problematic in stacked CDN setups where an old service worker with
919+ // old CSPs can remain cached if the content of the service worker itself is not changed.
920+ //
921+ // To ensure the service worker is refetched when CSPs are changed, we factor in
922+ // the CSP headers when generating the Etag.
923+ //
924+ // See https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE000025yeu9YAA/view
925+ // and https://salesforce-internal.slack.com/archives/C01GLHLBPT5/p1730739370922629
926+ // for more details.
927+
928+ const contentSecurityPolicyHeader = res . getHeaders ( ) [ 'content-security-policy' ]
929+
914930 // Serve the file, with a strong ETag
915- res . set ( 'etag' , getHashForString ( content ) )
931+ res . set ( 'etag' , getHashForString ( content + contentSecurityPolicyHeader ) )
916932 res . set ( CONTENT_TYPE , 'application/javascript' )
917933 res . send ( content )
918934 } ,
You can’t perform that action at this time.
0 commit comments