You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need a way to add response headers to service worker responses #31330
Need a way to add response headers to responses cached and returned by service worker responses. While using service workers with a CSP, we can run into issues like the one described here whose solution is to add a different CSP header for responses returned by service workers as described here.
I am facing a similar issue as described in the first link above and if can add a header like 'Content-Security-Policy: connect-src *;' to the cached responses returned by the service worker it should solve the problem.
Describe the solution you'd like
A way to add response headers for responses returned by a service worker
Describe alternatives you've considered
Tried using angular HttpInterceptors to see if I could intercept the service worker response and add the appropriate header.
Using plain JS instead of the angular package to have more control over the service worker responses.
If I understand the linked resources correctly, the solution is not to set special headers to responses from inside the SW script (that wouldn't help, since the request would have failed in the first place).
The solution is to set special CSP headers on the server to the response for the SW script. I.e., when the browsers requests ngsw-worker.js (the default name for the Angular SW script), the server should attach special CSP headers (e.g. Content-Security-Policy: connect-src *) to the response.
I am going to close this, since there is nothing to fix inside the Angular SW script, but feel free to continue the discussion below (or point out any mistakes in my understanding of the issue).
Activity
gkalpak commentedon Jun 28, 2019
If I understand the linked resources correctly, the solution is not to set special headers to responses from inside the SW script (that wouldn't help, since the request would have failed in the first place).
The solution is to set special CSP headers on the server to the response for the SW script. I.e., when the browsers requests
ngsw-worker.js(the default name for the Angular SW script), the server should attach special CSP headers (e.g.Content-Security-Policy: connect-src *) to the response.I am going to close this, since there is nothing to fix inside the Angular SW script, but feel free to continue the discussion below (or point out any mistakes in my understanding of the issue).
vinay-akkipet commentedon Jun 29, 2019
@gkalpak Thanks a ton for adding that comment before closing!! My bad I misconstrued the issue.
angular-automatic-lock-bot commentedon Sep 15, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.