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
configurable key for ngsw-bypass in service-worker #46984
Which @angular/* package(s) are relevant/related to the feature request?
@angular/pwa
Description
A customizable key for ngsw-bypass would be great if we can include some set of headers from ngsw-config.json
Also exclude URLs for API calls would be very helpful
Proposed solution
A field in ngsw-config.json giving option to omit in ngsw-worker.js
Alternatives considered
Right now, Im replacing the ngsw-bypass with Authorization to by pass all our API calls
Unfortunately, this is not possible at the moment. The reason is that the ngsw.json manifest that corresponds to each client is retrieved asynchronously, while the decision on whether to bypass the service worker or not has to be made synchronously.
Therefore, the logic for deciding this needs to be embedded into the service worker code and cannot depend on the configuration. #21197 will provide a way to address this, but there are not concrete plans on implementing it.
I am going to close this issue (in favor of #21197), but feel free to continue the discussion below.
What I meant is the string ngsw-bypass inside the generated service worker must be dynamic and configurable from ngsw-config.json. This change would not be runtime, just a build time.
The SW script is fixed and does not change at build time. The only thing that happens at build time is that ngsw-config.json is processed and converted to ngsw.json. The the SW will retrieve and use ngsw.json at run time.
So, without #21197, there is no way to modify the SW script at build time.
angular-automatic-lock-bot commented on Sep 1, 2022
Activity
nikithamunigala193 commentedon Jul 28, 2022
Waiting for resolution
bluestar39 commentedon Jul 28, 2022
+1
gkalpak commentedon Jul 28, 2022
Unfortunately, this is not possible at the moment. The reason is that the
ngsw.jsonmanifest that corresponds to each client is retrieved asynchronously, while the decision on whether to bypass the service worker or not has to be made synchronously.Therefore, the logic for deciding this needs to be embedded into the service worker code and cannot depend on the configuration. #21197 will provide a way to address this, but there are not concrete plans on implementing it.
I am going to close this issue (in favor of #21197), but feel free to continue the discussion below.
9thQuadrant commentedon Aug 1, 2022
What I meant is the string
ngsw-bypassinside the generated service worker must be dynamic and configurable fromngsw-config.json. This change would not be runtime, just a build time.gkalpak commentedon Aug 1, 2022
The SW script is fixed and does not change at build time. The only thing that happens at build time is that
ngsw-config.jsonis processed and converted tongsw.json. The the SW will retrieve and usengsw.jsonat run time.So, without #21197, there is no way to modify the SW script at build time.
angular-automatic-lock-bot commentedon Sep 1, 2022
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.