Skip to content

Commit 6ca1948

Browse files
fairlightethkernelwhisperer
authored andcommitted
chore: relax COOP on preview deploys (#7825)
## Summary - Sets `Cross-Origin-Opener-Policy` to `unsafe-none` for non-production Vercel deployments. - Keeps production on `same-origin-allow-popups`. ## Why Google Tag Assistant preview can lose its cross-origin opener/debug connection when the preview page sends a stricter COOP header. This branch gives us an isolated Vercel preview URL to verify whether relaxing COOP fixes the Tag Assistant connection without changing the original captcha analytics PR branch. ## Preview - https://swap-dev-git-agent-gtm-tag-assistant-coop-preview-cowswap-dev.vercel.app/?gtm_debug=x - Verified response header: `cross-origin-opener-policy: unsafe-none` ## Checks - `pnpm exec prettier --check apps/cowswap-frontend/vercel.ts` - `pnpm exec eslint apps/cowswap-frontend/vercel.ts` - `pnpm exec tsc --noEmit --pretty false --skipLibCheck --moduleResolution node16 --module Node16 --target ES2022 apps/cowswap-frontend/vercel.ts` - `curl -sI 'https://swap-dev-git-agent-gtm-tag-assistant-coop-preview-cowswap-dev.vercel.app/?gtm_debug=x'`
1 parent 33eaca1 commit 6ca1948

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

apps/cowswap-frontend/vercel.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ const csp = buildCsp([
6767
['upgrade-insecure-requests', []],
6868
])
6969

70+
const crossOriginOpenerPolicy = process.env.VERCEL_ENV === 'production' ? 'same-origin-allow-popups' : 'unsafe-none'
71+
7072
// ---------------------------------------------------------------------------
7173
// Vercel config
7274
// ---------------------------------------------------------------------------
@@ -87,9 +89,8 @@ export const config: VercelConfig = {
8789
routes.header('/(.*)', [
8890
// Controls which resources the browser is allowed to load; prevents XSS and data injection attacks.
8991
{ key: 'Content-Security-Policy', value: csp },
90-
// Isolates the browsing context so cross-origin pages cannot access window.opener,
91-
// while still allowing this page to open popups (needed for wallet connections).
92-
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin-allow-popups' },
92+
// Preview deploys use unsafe-none so Tag Assistant can keep its cross-origin debug connection.
93+
{ key: 'Cross-Origin-Opener-Policy', value: crossOriginOpenerPolicy },
9394
// Allows any origin to load this page as an iframe, required for the embeddable widget.
9495
{ key: 'Cross-Origin-Resource-Policy', value: 'cross-origin' },
9596
// Prevents browsers from MIME-sniffing a response away from the declared Content-Type.

0 commit comments

Comments
 (0)