Skip to content

Next.js 16 dev target renders but never hydrates under 127.0.0.1 (allowedDevOrigins blocks /_next/*) #751

Closed

Description

@Shugar03

What happened

With a target like:

app: {
  url: 'http://127.0.0.1:0',
  command: { executable: 'pnpm', args: ['exec', 'next', 'dev', '-p', '{port}'], cwd: 'app' },
}

every page renders (SSR HTML + accessible tree are all there), but no client JavaScript ever loads — the page never hydrates. Locators resolve, clicks land (:focus moves), and React handlers never fire. Symptoms look like a timing flake; retries don't help because hydration never happens at all.

Root cause

Next.js 16 blocks cross-origin requests to dev resources by default. next dev binds/identifies as localhost, and the run opens http://127.0.0.1:<port> — requests to /_next/* (client chunks, HMR) get rejected:

Blocked cross-origin request to Next.js dev resource /_next/hmr from "127.0.0.1".
To allow this host in development, add it to "allowedDevOrigins" in next.config.js

The trap

app.url with port 0 only accepts a loopback IP (127.0.0.1/[::1]) — localhost is rejected with INVALID_APP_URL — so the only fix is app-side:

// next.config.js
{ allowedDevOrigins: ['127.0.0.1'] }

Suggestion

Either document this in the web target docs (it will hit every Next.js ≥16 user running a dev target), or warn at runtime when the served app logs the Next cross-origin block. A sentence in the docs would have saved real debugging time.

Workaround confirmed working: adding allowedDevOrigins: ['127.0.0.1'] to next.config restores hydration and the suite passes.

Activity

  1. SachinD6 commented on Oct 2, 2026

    @SachinD6
    Contributor

    Fixed in #758. docs/starting-your-app.mdx now has a "Next.js dev targets" section with the allowedDevOrigins change, and skills/e2e/references/setup.md carries the same note. This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions