nextjs - ✅(Solved) Fix Fail to load worker-entrypoint.js in Next.js 16.2+ when COEP is 'require-corp' [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#92676Fetched 2026-04-12 13:23:15
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
issue_type_added ×1labeled ×1

Root Cause

With Next.js 16.2+ (all the way to canary), the message doesn't appear because the newly introduced worker-entrypoint.js file is blocked by the COEP policy.

Fix Action

Fixed

PR fix notes

PR #92682: Set Cross-Origin-Resource-Policy on /_next/static assets

Description (problem / solution / changelog)

Set Cross-Origin-Resource-Policy: same-origin on responses served from /_next/static/* in router-server.ts.

Why

Turbopack writes worker-entrypoint.js to /_next/static/ (added in #d23af53) and loads it with new Worker(...). When the document sets Cross-Origin-Embedder-Policy: require-corp, the browser blocks that fetch because Next.js does not send a CORP header for it. This breaks every app that enables COEP and uses a Worker on 16.2, a regression from 16.1.

same-origin is safe here because these are first-party build artifacts. The fix only sets the header when the user hasn't already set one via headers().

Fixes #92676

Test plan

New e2e test at test/e2e/app-dir/worker-coep:

  • loads a worker on a page with COEP require-corp and asserts the worker's message arrives
  • asserts /_next/static/<buildId>/_buildManifest.js responds with cross-origin-resource-policy: same-origin

Verified locally in dev/Turbopack, start/Turbopack, and dev/webpack. Without the fix, the CORP assertion fails with Expected: "same-origin" / Received: null.

<!-- NEXT_JS_LLM_PR -->

Changed files

  • packages/next/src/server/lib/router-server.ts (modified, +18/-11)
  • test/e2e/app-dir/worker-coep/app/layout.tsx (added, +8/-0)
  • test/e2e/app-dir/worker-coep/app/page.tsx (added, +19/-0)
  • test/e2e/app-dir/worker-coep/app/worker.ts (added, +1/-0)
  • test/e2e/app-dir/worker-coep/next.config.js (added, +24/-0)
  • test/e2e/app-dir/worker-coep/worker-coep.test.ts (added, +36/-0)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:30:44 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 24.11.1
  npm: 9.6.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.1-canary.33 // Latest available version is detected (16.2.1-canary.33).
  eslint-config-next: N/A
  react: 19.2.5
  react-dom: 19.2.5
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/lucach/nextjs-coep-worker-entrypoint-bug

To Reproduce

  1. Start the application (next dev)
  2. Open the browser console

Current vs. Expected behavior

Up to Next.js 16.1.*, the worker is successfully loaded and the console shows Message from worker: hello.

With Next.js 16.2+ (all the way to canary), the message doesn't appear because the newly introduced worker-entrypoint.js file is blocked by the COEP policy.

<img width="1002" height="391" alt="Image" src="https://github.com/user-attachments/assets/0dc359ef-5f5c-4be3-915a-911affd154b0" />

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:30:44 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 24.11.1
  npm: 9.6.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.1-canary.33 // Latest available version is detected (16.2.1-canary.33).
  eslint-config-next: N/A
  react: 19.2.5
  react-dom: 19.2.5
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

The problem has been introduced with https://github.com/vercel/next.js/commit/d23af53268d062ff70b7c12322750b85ed3a76ba

I suspect that worker-entrypoint.js is not fetched with the appropriate headers and thus blocked by COEP.

extent analysis

TL;DR

The issue can be resolved by ensuring the worker-entrypoint.js file is fetched with the appropriate headers to comply with the COEP policy.

Guidance

  • Verify that the worker-entrypoint.js file is being blocked by the COEP policy by checking the browser console for related error messages.
  • Investigate the changes introduced in the commit d23af53268d062ff70b7c12322750b85ed3a76ba to understand how the worker-entrypoint.js file is being fetched and how the headers can be modified to comply with COEP.
  • Check the Next.js documentation for any configuration options or workarounds related to COEP and worker entry points.
  • Consider testing with different versions of Next.js to confirm that the issue is indeed related to the changes introduced in version 16.2+.

Example

No code snippet is provided as the issue is related to a specific commit and configuration, and without more information, it's difficult to provide a concrete example.

Notes

The issue seems to be specific to the next dev stage and the Turbopack area, so any fixes or workarounds may need to be tailored to these specific conditions.

Recommendation

Apply a workaround to ensure the worker-entrypoint.js file is fetched with the appropriate headers, as the issue is likely related to the changes introduced in Next.js 16.2+.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING