Share localhost / FastAPI
Share a FastAPI dev server at a public URL
fastapi dev listens on 127.0.0.1:8000, and whk share 8000 gives it an HTTPS link. There is no host check to pass. The catch is Uvicorn's proxy headers, which are on by default and change where redirects go.
# terminal 1: the dev server
fastapi dev --no-proxy-headers
# terminal 2: the link
whk share 8000The 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.
FastAPI at a glance
- Dev server
fastapi dev --no-proxy-headers, port 8000- Share it
whk share 8000- Setting to add
- None for the host. Start the server with
--no-proxy-headerswhile sharing, so its redirects are ones the link can send back. - Without it
- A request for
/items/when the route is/itemsredirects tohttps://localhost:8000/items, which the visitor's browser cannot open. - Hot reload
fastapi devreloads the server when your code changes. It does not refresh the browser.- URLs and cookies
request.urlandurl_foruse theHostheader, so they saylocalhost:8000. Link with paths (url_for(...).path);/docsalready loads/openapi.jsonby path.
Your dev server gets each request with Host: localhost:8000; the public name travels in X-Forwarded-Host, with X-Forwarded-Proto: https. What your server sees has the rest.
Why redirects go to https://localhost:8000
Uvicorn applies X-Forwarded-Proto and X-Forwarded-For from addresses it trusts, and by default it trusts 127.0.0.1 and ::1. whk connects from your own machine, so the scheme becomes https and the client address becomes the visitor's. Uvicorn does not read X-Forwarded-Host, so the host stays localhost:8000.
The mix shows in anything absolute. Starlette's trailing-slash redirect, the one that sends /items/ to /items, answers with Location: https://localhost:8000/items. The link rewrites redirects to http://localhost:8000, which is what a local server normally sends, but not this https form, so the visitor's browser is sent to its own machine.
Turn the proxy headers off while sharing. The redirect is then http://localhost:8000/items, and the link returns it as https://<name>.sharehooks.cc/items:
fastapi dev main.py --no-proxy-headers
whk share 8000The same flag exists on uvicorn main:app --reload --no-proxy-headers. Without proxy headers request.client.host is 127.0.0.1; the visitor's address is still in the X-Forwarded-For header if you need it.
url_for, templates and /docs
request.url_for("static", path="/app.css") returns a full URL built from the Host header: http://localhost:8000/static/app.css. In a template that is a stylesheet the visitor's browser cannot load. Use the path instead, which is the same on localhost and on the link: url_for("static", path="/app.css").path.
The interactive docs need nothing. /docs asks for /openapi.json by path, and the schema has no servers entry unless you set a root path, so Swagger UI calls your API on whatever origin the page was opened from. Its own scripts and styles come from a CDN, not through the link.
Hosts, CORS and WebSockets
FastAPI adds no host check. If your app uses TrustedHostMiddleware, it compares the Host header, so allowed_hosts=["localhost"] keeps passing; a host it does not know gets 400 with Invalid host header.
A page served by the app and calling the same app is same-origin on the link, so CORSMiddleware is not involved. A separate frontend on another port is a second share and a second origin: allow that origin in CORSMiddleware, or serve both from one port. WebSocket routes pass through the link like any other request.
FastAPI questions
Start it with fastapi dev main.py --no-proxy-headers, then run whk share 8000 in another terminal. The CLI prints an HTTPS link on sharehooks.cc that reaches your app, /docs included, until you press Ctrl-C.
Starlette builds redirect URLs from the Host header, and through whk share that is localhost:8000. With Uvicorn's default proxy headers the scheme is https, giving https://localhost:8000, which the link does not rewrite. Start the server with --no-proxy-headers and the redirect comes back to the public address.
Yes. The page requests /openapi.json by path and sends API calls to the origin it was loaded from, so Try it out calls your local app through the link.
No. --forwarded-allow-ips widens which addresses Uvicorn trusts for proxy headers, and loopback is trusted already. --root-path is for an app mounted under a path prefix; a share serves the whole port at the root.
Sources
The FastAPI settings and messages on this page are from the official documentation and source for FastAPI 0.162, read on 12 November 2026. What the link does to a request is from the whk share docs.
Other frameworks
Send someone your FastAPI app
Sign up free, install the CLI and run whk share 8000.
No credit card