How to create SharedWorker with crossOriginIsolated = true in next.js
19:45 07 Mar 2026

If i trying new SharedWorker("./worker.ts", {...}) i have "failed to fetch worker scipt", if i build it with tsup to .js first i have crossOriginIsolated = false ( i have all
necessary headers set in next.config.ts ), i also tried webpack entries and create it from _next/static i always have crossOriginIsolated = false

this is my next.config.ts (
from my attempts using webpack entries )

i am using last version of Chrome


const nextConfig: NextConfig = {
    webpack(config) {
        config.plugins.push(
            new webpack.EntryPlugin(config.context, "./src/workers/market-shared-worker.ts", {
                name: "static/chunks/market-shared-worker",
                filename: "static/chunks/market-shared-worker.js",
            }),
        );

        return config;
    },
    async headers() {
        return [
            {
                source: "/(.*)",
                headers: [
                    { key: "Cross-Origin-Opener-Policy", value: "same-origin" },
                    { key: "Cross-Origin-Embedder-Policy", value: "require-corp" },
                    { key: "Cross-Origin-Resource-Policy", value: "cross-origin" },
                ],
            },
        ];
    },
};

export default nextConfig;
next.js webpack cross-origin-embedder-policy cross-origin-opener-policy shared-worker