Skip to content

Conversation

@amoore108
Copy link
Contributor

@amoore108 amoore108 commented Nov 25, 2025

Summary

Adds logic to set response headers outside of Next middleware in the event that we need to upgrade Next without a fix in place for vercel/next.js#86303

Code Changes

  • Moves localhost rewrite of the sw.js file from middleware to next.config as it will be known at build time where its location is
  • Should behave exactly the same as it does when it was in Middleware. This is just a small optimisation to remove that processing from Middleware
  • Changes isLocal check in next.config to check against SIMORGH_APP_ENV instead of SIMORGH_PUBLIC_STATIC_ASSETS_ORIGIN
  • Adds cspHeaderResponseForNextDocumentContext function specifically for use in the _document file. This is mostly the same as the cspHeaderResponse function in the same file, but handles header setting a bit differently
  • Adds logic to _document to set the header values on getInitialProps

Developer Checklist

  • UX
    • UX Criteria met (visual UX & screenreader UX)
  • Accessibility
    • Accessibility Acceptance Criteria met
    • Accessibility swarm completed
    • Component Health updated
    • P1 accessibility bugs resolved
    • P2/P3 accessibility bugs planned (if not resolved)
  • Security
    • Security issues addressed
    • Threat Model updated
  • Documentation
    • Docs updated (runbook, READMEs)
  • Testing
    • Feature tested on relevant environments
  • Comms
    • Relevant parties notified of changes

Testing

  • Manual Testing required?
    • Local (Ready-For-Test, Local)
    • Test (Ready-For-Test, Test)
    • Preview (Ready-For-Test, Preview)
    • Live (Ready-For-Test, Live)
  • Manual Testing complete?
    • Local
    • Test
    • Preview
    • Live

Additional Testing Steps

  1. List the steps required to test this PR.

Useful Links

@amoore108 amoore108 self-assigned this Nov 25, 2025
@amoore108 amoore108 marked this pull request as ready for review November 25, 2025 17:37
@amoore108 amoore108 marked this pull request as draft November 25, 2025 22:35
@amoore108 amoore108 changed the title Move sw.js rewrite to next.config [DNM] Set response headers outside of Next middleware Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants