Nope, unfortunately the suggested did not help. I set the header for Content-Security-Policy
in the next config along with other headers like:
{
// source: '/:path*',
source: '/(.*)',
headers: [
{
key: 'Content-Security-Policy',
value:
'frame-ancestors https://*.builder.io https://builder.io http://localhost:3000',
},
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
{ key: 'Cross-Origin-Resource-Policy', value: 'same-origin' },
{ key: 'Cross-Origin-Embedder-Policy', value: 'require-corp' },
],
},
tried setting these directly in the meta tags:
<meta name="Cross-Origin-Opener-Policy" content="same-origin"></meta>
<meta
name="Content-Security-Policy"
content="frame-ancestors https://*.builder.io https://builder.io http://localhost:3000;"
></meta>
<meta name="Cross-Origin-Opener-Policy" content="same-origin"></meta>
<meta name="Cross-Origin-Resource-Policy" content="same-origin"></meta>
<meta name="X-Frame-Options" content="SAMEORIGIN"></meta>
<meta
name="Cross-Origin-Window-Policy"
content="Allow-PostMessage"
></meta>
Still nothing, then i added this conditional check everywhere the window has been used including in the partytown load function:
if (typeof window !== 'undefined') {
...
}
did not help either.
so as a solution (last resort), as the error only appears on localhost
i had to disable the nextScriptWorker
in the development
environment like this.
experimental: {
/**
* Disable nextScriptWorkers on dev to avoid the following error:
* SecurityError: Permission denied to access property "dispatchEvent" on cross-origin object
*/
...(isDev ? { nextScriptWorkers: false } : { nextScriptWorkers: true }),
},
So if you have any other suggestion i would be glad to test them out as well.
Thanks for the support,
Best regards