pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/angular/angular/pull/67918

b.githubassets.com/assets/actions-26401580c700f528.css" /> fix(service-worker): bypass CSP violation reports by pierluigilenoci · Pull Request #67918 · angular/angular · GitHub
Skip to content

fix(service-worker): bypass CSP violation reports#67918

Open
pierluigilenoci wants to merge 1 commit intoangular:mainfrom
pierluigilenoci:fix/sw-csp-report-bypass
Open

fix(service-worker): bypass CSP violation reports#67918
pierluigilenoci wants to merge 1 commit intoangular:mainfrom
pierluigilenoci:fix/sw-csp-report-bypass

Conversation

@pierluigilenoci
Copy link
Copy Markdown

Summary

The Angular service worker intercepts all fetch events, including CSP violation reports (Content-Type: application/csp-report) and Reporting API reports (Content-Type: application/reports+json). These are POST requests sent autonomously by the browser, and intercepting them causes errors due to CORS restrictions or redirect mode mismatches.

This PR adds an early check in the SW onFetch handler: if the request is a POST with a CSP/Reporting API content-type, the SW returns immediately without calling event.respondWith(), letting the browser handle the request natively.

Changes

  • packages/service-worker/worker/src/driver.ts: Added content-type check after existing ngsw-bypass check
  • packages/service-worker/worker/test/happy_spec.ts: Added 5 tests (positive + negative cases)

Fixes #31477

The Angular service worker intercepts all fetch requests, including
CSP violation reports (Content-Type: application/csp-report) and
Reporting API reports (Content-Type: application/reports+json). These
are POST requests sent autonomously by the browser, and handling them
in the SW causes errors due to CORS restrictions or redirect mode
mismatches, preventing the reports from reaching the server.

This change detects these report requests by checking for POST method
combined with the specific content-type headers, and lets them pass
through to the network without SW intervention.

Fixes angular#31477

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@pullapprove pullapprove bot requested a review from kirjs March 27, 2026 15:34
@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 27, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot bot added the area: service-worker Issues related to the @angular/service-worker package label Mar 27, 2026
@ngbot ngbot bot added this to the Backlog milestone Mar 27, 2026
@pierluigilenoci
Copy link
Copy Markdown
Author

@googlebot I signed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: service-worker Issues related to the @angular/service-worker package cla: no

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service Worker is blocking CSP violation reports

2 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy