Security headers › Cross-Origin-Opener-Policy
How to add the Cross-Origin-Opener-Policy header in Next.js
COOP isolates your page's browsing context from cross-origin windows it opens or that open it.
Next.js configuration (next.config)
async headers() {
return [
{
source: "/:path*",
headers: [{ key: "Cross-Origin-Opener-Policy", value: "same-origin" }],
},
];
}Add the headers() function to your Next.js config and restart or redeploy. Headers set by a proxy or CDN in front can override these.
Before you deploy
same-origin can break OAuth or payment pop-ups that rely on window.opener. Use same-origin-allow-popups in that case.
Verify it works
curl -sI https://your-site.com | grep -i cross-origin-opener-policyOr run a free Korrali Web scan to check this and every other security header at once.