Decouple API security headers from PageSpeed processing #213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR removes the dependency between the API security headers middleware and the PageSpeed processing logic.
ApiSecurityHeadersshould only be responsible for adding security-related HTTP headers and should not be gated by PageSpeed enable/disable rules. The middleware now applies headers solely based on the response content type.Motivation and context
Security headers must be applied consistently and independently of performance-related middleware.
Previously, API security headers were skipped whenever PageSpeed processing was disabled or excluded for a request, which could unintentionally weaken the security posture of API responses. This change fixes that coupling and ensures security headers are always applied to eligible API responses.
How has this been tested?
Manually verified by:
application/jsonNo existing behavior for PageSpeed HTML processing is affected.
Screenshots (if appropriate)
N/A
Types of changes
Checklist: