Share localhost / SvelteKit
Share a SvelteKit dev server at a public URL
npm run dev serves a SvelteKit app on localhost:5173 through Vite, and whk share 5173 gives it an HTTPS link. In development everything works as it is, form actions included. The setting people look for belongs to production builds, and it matters here only if you share npm run preview.
# 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.
SvelteKit at a glance
- Dev server
npm run dev, port 5173- Share it
whk share 5173- Setting to add
- None in dev. To share a production build (
npm run preview), setpaths.originto the link.csrf.trustedOriginscovers form actions only, not remote functions. - Without it
- In dev, nothing. A shared preview answers form posts with
403andCross-site POST form submissions are forbidden, and remote function calls with403andCross-site remote requests are forbidden. - Hot reload
- Yes. It is Vite's HMR on the dev server's own port, and the client connects to the host the page came from.
- URLs and cookies
event.url.originishttp://localhost:5173on the server.redirect(303, '/path')and relative links work;paths.origintells a build its public origin.
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.
Development needs nothing
A SvelteKit project is a Vite project, so the host check is Vite's: localhost is always allowed, and whk share sends Host: localhost:5173. Pages, server load functions and HMR come through with no configuration.
Form actions do too. SvelteKit protects them against cross-site posts by comparing the request's Origin with its own, but in the words of its docs, CSRF checks only apply in production, not in local development. A form posted through the link reaches your action in npm run dev.
Sharing a production preview
npm run build and npm run preview serve the built app on port 4173, and there the check is live. SvelteKit derives its own origin from the Host header, http://localhost:4173, while the browser sends Origin: https://<name>.sharehooks.cc. The post is refused with status 403 and Cross-site POST form submissions are forbidden. The response has no content type; the link shows it as plain text so you can read it.
Tell SvelteKit the app's public origin with paths.origin. That fixes both kinds of post. csrf.trustedOrigins also lets form actions through, but not remote form and command functions: a production build refuses those from any other origin with 403 and Cross-site remote requests are forbidden, whatever trustedOrigins says. In SvelteKit 3 both are options of the sveltekit() plugin in vite.config:
vite.config.ts
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
sveltekit({
// Say where the app is served from: covers form actions and remote functions
paths: { origin: "https://acme.sharehooks.cc" },
// Or, for form actions only (remote functions stay refused):
// csrf: { trustedOrigins: ["https://acme.sharehooks.cc"] },
}),
],
});Either value is a complete origin and is matched exactly: https://*.sharehooks.cc does not work. A random name changes every session, so this is one place where a reserved name earns its keep (whk share 4173 --name acme). trustedOrigins: ['*'] turns the check off for every site and is not something to leave in. Rebuild after changing either option.
What the server believes about its URL
In dev and in preview, event.url is built from the Host header, so server code sees http://localhost:5173 and event.getClientAddress() returns your own machine's address. Relative links, redirect(303, '/login') and fetch inside load are unaffected.
The environment variables for running behind a proxy (ORIGIN, PROTOCOL_HEADER, HOST_HEADER, ADDRESS_HEADER) belong to adapter-node's built server, started with node build, which listens on port 3000. They have no effect on vite dev or vite preview. If you share a node build server, ORIGIN=https://acme.sharehooks.cc node build gives it the public origin, unless paths.origin is set, which takes precedence.
SvelteKit questions
The built app thinks its origin is localhost while the form's Origin is the tunnel's address. Set paths.origin to the tunnel's full origin, for example "https://acme.sharehooks.cc"; with adapter-node you can set the ORIGIN environment variable instead. csrf.trustedOrigins also works for form actions, but remote functions ignore it and answer Cross-site remote requests are forbidden. Wildcards are not matched.
Yes. SvelteKit's CSRF origin check runs only in production builds, so in npm run dev a form posted from the public link reaches the action.
Not in SvelteKit 3. The option was removed in favour of csrf.trustedOrigins, and setting it stops the dev server with a configuration error. Trust the specific origin you need instead.
Yes. HMR is Vite's, on the same port as the app, and its client connects to the host the page was loaded from, so updates reach pages opened through the link.
Sources
The SvelteKit settings and messages on this page are from the official documentation and source for SvelteKit 3.2, read on 12 November 2026. What the link does to a request is from the whk share docs.
Other frameworks
Send someone your SvelteKit app
Sign up free, install the CLI and run whk share 5173.
No credit card