How to set Cross-Origin-Opener-Policy while using Reactjs

3k Views Asked by At

How can I resolve the 'Cross-Origin-Opener-Policy policy would block the window.closed call' error in my React application? This error seems to be related to the Cross-Origin-Opener-Policy (COOP) policy set on the server. How can I handle this error and ensure that my React app functions correctly while adhering to the COOP policy restrictions?

enter image description here

On searching so far I understood that I need to set

Cross-Origin-Opener-Policy: unsafe-none
Cross-Origin-Opener-Policy: same-origin-allow-popups
Cross-Origin-Opener-Policy: same-origin

But I don't know where and how to set.

1

There are 1 best solutions below

3
Vishu Singh On

CREATE CRACO.CONFIG.JS

module.exports = { devServer: { headers: {'Cross-Origin-Embedder-Policy': 'require-corp', 'Cross-Origin-Opener-Policy': 'same-origin', }, }, };