Share localhost / Vite
Share a Vite dev server at a public URL
npm run dev serves a Vite app on localhost:5173, whichever template it started from: React, Vue or Svelte. whk share 5173 gives that port an HTTPS link, and hot module replacement keeps working for whoever has the page open.
# terminal 1: the dev server
npm run dev
# terminal 2: the link
whk share 5173The 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.
Vite at a glance
- Dev server
npm run dev, port 5173- Share it
whk share 5173- Setting to add
- None for
whk share.server.allowedHostsis checked against theHostheader, which arrives aslocalhost:5173. - Without it
- Nothing through
whk share. Other tunnels get403andBlocked request. This host ("<host>") is not allowed. - Hot reload
- Yes. The HMR client opens its WebSocket to the host and port the page was loaded from, and the link carries it.
- URLs and cookies
- Nothing to set for a client-rendered app. An API on another port is not reachable through one share: put it behind
server.proxy.
Your dev server gets each request with Host: localhost:5173; the public name travels in X-Forwarded-Host, with X-Forwarded-Proto: https. What your server sees has the rest.
Why the host check passes
Vite responds only to hosts it knows. localhost, domains under .localhost and all IP addresses are allowed by default; a request with any other Host gets status 403 and the text Blocked request. This host ("<host>") is not allowed., followed by the instruction to add that host to server.allowedHosts in vite.config.js. Most tunnels pass their public hostname as Host, which is how people meet that message.
whk share sends Host: localhost:5173 and carries the public name in X-Forwarded-Host, which Vite does not look at. The check passes with an untouched vite.config, for the React, Vue and Svelte templates alike: all three run plain vite with no server block.
For a proxy that does send the public Host, the setting takes a leading dot for a domain and its subdomains:
vite.config.ts
import { defineConfig } from "vite";
export default defineConfig({
server: {
// Not needed for whk share; for proxies that send the public Host
allowedHosts: [".sharehooks.cc"],
},
});Do not reach for allowedHosts: true. Vite's docs warn that it lets any website send requests to your dev server through DNS rebinding and download your source code.
HMR through the link
Unless told otherwise, Vite's client builds its WebSocket address from the URL its own script was loaded from. A page opened at https://<name>.sharehooks.cc connects to wss://<name>.sharehooks.cc/ with the token Vite put in the page, the link carries the socket to your dev server, and the server accepts it: it checks the Host header and that token.
If you once set server.hmr.port, server.hmr.clientPort or server.hmr.host for another proxy (named server.ws since Vite 8.1; the old names still work), take them out for sharing. A share is one port, and a client told to dial a different one will not find it. When the socket cannot connect, the client tries the dev server's own address directly, which on a visitor's machine is their localhost: the page works, the console shows [vite] failed to connect to websocket, and updates stop arriving.
Ports, IPv6 and vite preview
The default port is 5173. If it is taken, Vite moves to the next free port unless server.strictPort is set, so share the port Vite prints.
Vite listens on localhost, which on many systems means the IPv6 address ::1 and nothing on 127.0.0.1. whk share 5173 tries IPv4 and then IPv6, so it reaches the server either way. whk share 127.0.0.1:5173 connects to IPv4 only and can report that nothing is running while Vite is up.
vite preview serves the production build on port 4173 and checks hosts the same way (preview.allowedHosts defaults to server.allowedHosts). whk share 4173 shares the build.
An API on another port
A page loaded from the link can only reach what is on the shared port. If your frontend calls http://localhost:8000 directly, that address is the visitor's own machine. Route the API through the dev server with server.proxy, so the browser asks the link for /api/... and Vite passes it on locally. The page and its API are then one origin, and server.cors, whose default allows only localhost origins, does not come into it.
Vite questions
Not with whk share: Vite receives Host: localhost:5173, which is allowed by default. With a tunnel or reverse proxy that passes its public hostname as Host, add it, for example allowedHosts: [".example.com"].
Since Vite 6.0.9 (and 5.4.12 and 4.5.6) the dev server answers only localhost, .localhost domains, IP addresses and the hosts listed in server.allowedHosts. A request with another Host header gets 403 and that message, which names the host to add.
Yes. By default the HMR client connects its WebSocket to the host and port the page came from, and whk share passes WebSockets through. Remove any server.hmr port or host overrides made for another proxy.
Yes. The create-vite templates for React, Vue and Svelte all start the same dev server with npm run dev on port 5173 and no server settings of their own, so they behave the same through the link.
Sources
The Vite settings and messages on this page are from the official documentation and source for Vite 8.3, read on 12 November 2026. What the link does to a request is from the whk share docs.
Other frameworks
Send someone your Vite app
Sign up free, install the CLI and run whk share 5173.
No credit card