Skip to content

Share localhost / Nuxt

Share a Nuxt dev server at a public URL

nuxt dev serves your app on localhost:3000, and whk share 3000 gives it an HTTPS link. Pages and HMR come through without a setting. The one surprise is server-side: the URL Nuxt reports while rendering is not the one in the visitor's address bar.

# terminal 1: the dev server
npm run dev

# terminal 2: the link
whk share 3000

The link is https://<name>.sharehooks.cc and works until you press Ctrl-C. No whk yet? Install it and log in, which takes a minute.

Start free:
or sign up with email

Nuxt at a glance

Dev server
npm run dev, port 3000
Share it
whk share 3000
Setting to add
None for whk share. Nuxt's dev server checks the Host header, which arrives as localhost:3000.
Without it
Nothing through whk share. Other tunnels get 403 and Vite's Blocked request. This host ("<host>") is not allowed.
Hot reload
Yes. In Nuxt 4 the HMR WebSocket is attached to the dev server itself, so it uses the same port as the page.
URLs and cookies
On the server useRequestURL() returns https://localhost:3000/...; in the browser it returns the public URL. Pass { xForwardedHost: true } to make them agree.

Your dev server gets each request with Host: localhost:3000; the public name travels in X-Forwarded-Host, with X-Forwarded-Proto: https. What your server sees has the rest.

The host check and HMR

Nuxt's dev server is Vite and Nitro behind the Nuxt CLI. Both Vite and the CLI's own pages accept localhost, names under .localhost and IP addresses, and refuse any other Host with 403: Vite's text is Blocked request. This host ("<host>") is not allowed., the CLI's is Forbidden: this host is not allowed. Through whk share the Host is localhost:3000, so neither appears.

The HMR socket is where older Nuxt setups broke behind one-port proxies: it used a port of its own, 24678. Nuxt 4 attaches Vite's HMR WebSocket to the main dev server, at /_nuxt/ on the page's port, and the client dials the host the page was loaded from. A page opened through the link keeps receiving updates.

For a proxy that passes the public hostname on, the setting is Vite's, set through Nuxt:

nuxt.config.ts

export default defineNuxtConfig({
  vite: {
    server: {
      // Not needed for whk share; for proxies that send the public Host
      allowedHosts: [".sharehooks.cc"],
    },
  },
});

useRequestURL() on the server

During server rendering, useRequestURL() takes the scheme from X-Forwarded-Proto and the host from the Host header, so it returns https://localhost:3000/.... In the browser the same call reads the address bar and returns https://<name>.sharehooks.cc/.... Render that value into the page (a canonical link, a share URL) and the server and client disagree.

Nuxt does not trust X-Forwarded-Host unless asked. The option is on the composable and on the server utilities it wraps:

// In a component or page
const url = useRequestURL({ xForwardedHost: true });

// In a server route
const url = getRequestURL(event, { xForwardedHost: true, xForwardedProto: true });

Nuxt's docs attach a condition: trust those headers only behind a proxy you control that overwrites them. The link sets X-Forwarded-Host and X-Forwarded-Proto itself on every request. The same goes for the visitor's address: getRequestIP(event) ignores X-Forwarded-For unless called with { xForwardedFor: true }.

Ports and nuxt dev --tunnel

The port is 3000 unless NUXT_PORT, NITRO_PORT or PORT is set, in that order, or devServer.port or --port says otherwise. If the port is busy Nuxt picks another unless --strictPort is given, so share the one it prints.

Nuxt's CLI has a tunnel flag of its own, nuxt dev --tunnel, which opens a Cloudflare quick tunnel. whk share is for when you want the same link each time (a reserved name), a password on it, or to see what visitors requested with whk shares log.

Nuxt questions

Sources

The Nuxt settings and messages on this page are from the official documentation and source for Nuxt 4.6, read on 12 November 2026. What the link does to a request is from the whk share docs.

Other frameworks

All 14 framework guides

Send someone your Nuxt app

Sign up free, install the CLI and run whk share 3000.

or sign up with email

No credit card