Fix guides · Cursor, Claude Code, v0, Bolt, Lovable, Replit ·
Fix "Cross-Origin-Opener-Policy policy would block the window.closed call"
Cross-Origin-Opener-Policy policy would block the window.closed call.
This console message appears when your site opens a sign-in popup (Google, Firebase signInWithPopup, Auth0, Supabase OAuth in a popup) and a Cross-Origin-Opener-Policy header cuts the connection between your page and the popup. If login still works, it's a harmless warning. If the popup stays blank, never closes or the login promise never resolves, your site (or the auth page) sends Cross-Origin-Opener-Policy: same-origin; change it to same-origin-allow-popups or use a redirect login instead.
Common causes – and how to tell which one you have
1. Your site sends Cross-Origin-Opener-Policy: same-origin
How to tell: In DevTools → Network, click the main document request of your page and look at Response Headers. If you see Cross-Origin-Opener-Policy: same-origin, the popup is cut off from your page.
Fix: Change the header to same-origin-allow-popups for the pages that open the login popup, in next.config headers(), vercel.json, netlify.toml / _headers or your server middleware.
2. A security middleware sets COOP for you (for example helmet)
How to tell: You never wrote a COOP header, but your Express or Node server uses helmet() or a security-headers package, which sends Cross-Origin-Opener-Policy: same-origin by default.
Fix: Configure it explicitly, for example helmet({ crossOriginOpenerPolicy: { policy: 'same-origin-allow-popups' } }).
3. COOP/COEP set for SharedArrayBuffer or WebAssembly
How to tell: You (or a template) added Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp to enable SharedArrayBuffer, ffmpeg.wasm or WebContainers, and popup login broke afterwards.
Fix: Apply those strict headers only to the routes that need them, not the login page, or switch the login to a redirect flow (signInWithRedirect / OAuth redirect) on those pages.
4. It's only a warning from the auth library
How to tell: The message appears, but the user is signed in correctly afterwards. Google's and Auth0's popup scripts poll window.closed, and Chrome logs this when the auth page itself sends a COOP header.
Fix: Nothing to fix if login completes. Don't change security headers just to silence the console.
5. The popup is opened outside a click or blocked
How to tell: The popup flashes or never appears, often on mobile or in Safari, and the console also mentions a blocked popup.
Fix: Call signInWithPopup directly inside the click handler (no await before it), or use the redirect flow, which works more reliably on mobile.
How to fix it
- Check whether login actually fails. If the user ends up signed in, the message is only a warning.
- Open DevTools → Network, reload, click the first document request and look for Cross-Origin-Opener-Policy in Response Headers.
- Search your project for Cross-Origin-Opener-Policy, crossOriginOpenerPolicy and helmet to find where the header comes from.
- Set it to same-origin-allow-popups on the pages that open the login popup (or remove it if you don't need it) and redeploy.
- If you need same-origin for SharedArrayBuffer or WebAssembly, keep it only on those routes or switch login to a redirect flow.
- Test the login again in a private window and confirm the popup closes and the user is signed in.
Using Lovable, Bolt or v0?
In Lovable, Bolt or v0, first check whether login really fails or only logs the warning. If it fails, tell the AI: "Popup login breaks because of a Cross-Origin-Opener-Policy header. Find where it's set and change it to same-origin-allow-popups, or switch to the redirect login." If you publish through a host with its own header settings, check those too.
Using Cursor, Claude Code or Windsurf?
Ask Cursor or Claude Code to grep the repo for Cross-Origin-Opener-Policy, crossOriginOpenerPolicy, Cross-Origin-Embedder-Policy and helmet, and to show the live response headers with curl -I https://your-site. Have it scope strict COOP/COEP to the routes that need them and confirm the popup login works in a private window afterwards.
The “fix” to avoid
Agents often remove all security headers, or switch COOP to unsafe-none for the whole site, just to silence the console. If login already works, the warning is harmless; if it doesn't, same-origin-allow-popups on the login pages is enough.
Copy-paste fix prompt for your AI coding tool
Paste this into Cursor, Claude Code, Lovable or Bolt:
My popup login (Google / Firebase signInWithPopup / OAuth popup) logs "Cross-Origin-Opener-Policy policy would block the window.closed call" and the popup never finishes. Find where my app sets Cross-Origin-Opener-Policy (next.config headers, vercel.json, netlify.toml, _headers, server middleware, helmet defaults). Change it to same-origin-allow-popups for the pages that open the login popup, and keep same-origin plus Cross-Origin-Embedder-Policy only on routes that truly need SharedArrayBuffer. Make sure the popup is opened directly in the click handler. If popups stay unreliable on mobile, add a redirect-based login as fallback. Show me the response headers before and after.
Questions people ask
Can I ignore this warning?
Yes, if the user is signed in after the popup. Google and Auth0 scripts trigger it while checking whether the popup was closed. Only fix it when the login actually hangs or the popup stays blank.
What does same-origin-allow-popups do?
It keeps your page isolated from other sites' windows, but still lets popups your page opens talk back to it. That's what OAuth popups need.
What about "Navigation was blocked by Cross-Origin-Opener-Policy"?
It's the same header at work: the popup or tab was moved to a separate browsing context. Check the COOP header on your page and the auth page in the same way.
Official documentation
- MDN: Cross-Origin-Opener-Policy
- Google Identity: Cross-Origin-Opener-Policy for popups
- Firebase: Best practices for signInWithRedirect