Skip to main content
← All guides

Fix Next.js “Blocked cross-origin request to Next.js dev resource”

Why qURL here

Keep the app private on your machine and invite the people you choose by email: each verifies their address and saves a passkey, with no account needed, and comes back until you revoke them. Hot reload and Server Actions work through qURL™, so they see the live next dev build, edits included, with nothing to deploy. For a quick look, send a one-time qURL link instead.

See how sharing the live app compares to deploying a preview →

Steps

Share the running next dev build with qURL: hot reload and Server Actions work through the link while your app stays on your machine with no public URL. Set QURL_DEV_ORIGIN_HOST to the exact browser hostname for dev resources and Server Actions, then restart. The reviewer sees your edits as you make them, with nothing to deploy.

  1. Read the origin from the log

    next dev logs “Blocked cross-origin request to Next.js dev resource … from “host”” and answers 403. The exact wording varies by release. Next.js 16.1 and earlier only warned: “Cross origin request detected from … to /_next/* resource.”

  2. Add the tunnel’s hostname to allowedDevOrigins

    Next.js matches only the hostname of the request’s Origin, so write entries without https:// and without a port. For dev resources and Server Actions, set QURL_DEV_ORIGIN_HOST to the exact r_….qurl.site hostname from the browser address bar, without https://, a port or a path. The configuration below adds only that hostname in development. A wildcard such as *.qurl.site would also let other publishers’ pages load your dev resources. Unlike allowedDevOrigins, serverActions.allowedOrigins also applies to production builds, so keep the development guard and never use a whole-domain wildcard there. For next.config.ts or next.config.mjs, export the same object with export default instead of module.exports.

    // next.config.js
    module.exports = {
      allowedDevOrigins:
        process.env.NODE_ENV === 'development' && process.env.QURL_DEV_ORIGIN_HOST
          ? [process.env.QURL_DEV_ORIGIN_HOST]
          : [],
      experimental: {
        serverActions: {
          // Development only: the hostname from the browser bar, without https:// or a port.
          allowedOrigins:
            process.env.NODE_ENV === 'development' && process.env.QURL_DEV_ORIGIN_HOST
              ? [process.env.QURL_DEV_ORIGIN_HOST]
              : [],
        },
      },
    }
  3. Restart next dev

    Ask the recipient to send you the exact browser hostname from the page they just opened. They must keep that page open; do not open their single-use link yourself. Set QURL_DEV_ORIGIN_HOST to that hostname (replace r_your-link below), restart next dev, and ask them to reload the same page. This configuration trusts one recipient origin at a time; update it for each new browser session. Next.js reads allowedDevOrigins at start-up. Bind next dev to 127.0.0.1 so your app stays on this computer and nothing listens on your network.

    QURL_DEV_ORIGIN_HOST=r_your-link.qurl.site npx next dev -H 127.0.0.1

What the recipient sees

With the origin allowed, the page and its dev resources load through the link, and the hot reload socket can connect.

Troubleshooting

Troubleshooting
If you seeDo this
qurl publish says the local app is not accepting TCP connectionsStart the app first and check that curl works on the same address. qurl publish connects to localhost as 127.0.0.1, so if your app listens only on IPv6 (on macOS or Linux, lsof -iTCP -sTCP:LISTEN -nP shows [::1]), publish 'http://[::1]:PORT' instead, or start the dev server with --host 127.0.0.1 and publish that address. Neither requires listening on your LAN. Keep the quotes: zsh treats the brackets as a pattern.
The recipient sees “Access link invalid”The link was already used or has expired. Run qurl share again and send the new link.
Show 6 more fixes
More troubleshooting
If you seeDo this
The recipient sees “Resource not found”The resource was deleted after the link was made. Publish the app again, then run qurl share and send the new link.
publish rejects http://127.0.0.1 with “only HTTPS URLs are allowed”, asks you to log in, or prints no Access: lineYour qURL CLI is out of date. On macOS run brew update, then brew upgrade qurl; elsewhere install the latest release. After updating, qurl --version prints 3.4.1 or later, and every publish is private by default.
publish says this Linux session “can’t reach a systemd user manager”You are in a container or sandbox without a user service manager. Run qurl publish with --foreground; sharing lasts as long as that process runs. Container and CI setup →
publish says “Quota Exceeded” with “protected resource limit reached”, or “Your qURL account has reached a plan limit”You can see this without an account: a device with no account can keep up to 3 active resources, with links that last up to 24 hours. Run qurl list --status active, then qurl delete <CRID> for any you no longer need (it asks you to confirm; --yes skips that). qurl stop keeps the resource, so it does not free a slot.
Server Actions fail with “Invalid Server Actions request”Set QURL_DEV_ORIGIN_HOST to the exact r_….qurl.site browser hostname and restart next dev. The development-only configuration above adds that host to experimental.serverActions.allowedOrigins; do not add *.qurl.site there.
The browser origin is still blockedSet QURL_DEV_ORIGIN_HOST to the exact hostname from the recipient’s browser address bar, without https://, a port or a path. Set it in the same shell used to restart npx next dev.

Frequently Asked Questions

Why did this start in Next.js 16.2?

Earlier releases warned about cross-origin dev requests and allowed them. Next.js 16.2 enforces the dev-origin guard by default, so a tunnel’s hostname must now be listed in allowedDevOrigins.

Does this fix work on Next.js 16.4?

Yes. Use allowedDevOrigins for dev resources and hot reload. For Server Actions, use the development-only exact-host configuration above: the browser is on r_….qurl.site while the app receives c-….qurl.site.

Does allowedDevOrigins affect production?

No. allowedDevOrigins applies only to next dev. serverActions.allowedOrigins also applies to production builds, which is why the example enables the exact browser hostname only when NODE_ENV is development.

Which pattern do I add for qURL?

For dev resources and Server Actions, put only the exact browser hostname, such as r_your-link.qurl.site, in QURL_DEV_ORIGIN_HOST and keep the development-only guard shown above. Trusting a wildcard there would also trust other publishers’ pages.

Who else can reach my app while the link is open?

Opening the link starts a session for that browser, which lasts 1 hour by default. After a browser opens it, another browser on the same public IP cannot use its access. A script or agent that opens the link without a browser is admitted by its network address instead, which other devices on that public IP share until the session ends. A link admits whoever opens it: the API’s IP and country rules do not apply to the signed links qurl share issues. Keep your app’s own sign-in for anything sensitive.

Publish your app now

Install the CLI, then run one command. No sign-up, no API key.

Install the CLI →

Book a pilot

Tell us what to hide. We’ll scope a pilot.

Enterprise starts with a paid pilot on one application, typically 60 to 90 days, credited in full toward year one if you convert within 60 days. After that, an annual package sized to what you protect, not per seat.