Share localhost / Laravel
Share a Laravel app at a public URL
php artisan serve listens on localhost:8000, and whk share 8000 gives it an HTTPS link. Laravel answers any host, so the page loads at once; what needs attention is where its links and assets point.
# terminal 1: the dev server
php artisan serve
# 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.
Laravel at a glance
- Dev server
php artisan serve, port 8000- Share it
whk share 8000- Setting to add
- No host setting: Laravel answers every
Hostunless you turned ontrustHosts. AddtrustProxiesso generated URLs use the public name. - Without it
- No error page. Links and assets from
url(),route()andasset()point athttp://localhost:8000, which is the visitor's own machine, so styles and scripts are missing. - Hot reload
- Not through the link: Vite's dev server is a second port. Run
npm run buildand reload by hand. - URLs and cookies
trustProxiesmakes URLs useX-Forwarded-HostandX-Forwarded-Proto.APP_URLis for URLs made outside a request (Artisan, queues). Session cookies need no change.
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.
Trust the proxy, or URLs point at localhost
During a request Laravel generates URLs from the request's own scheme and host. Through the link those are http and localhost:8000, so every route(), url() and asset() call writes http://localhost:8000/... into the page. Redirects to such an address come back to the link, but a stylesheet or script tag does not: the visitor's browser looks for it on their own machine.
Laravel's TrustProxies middleware reads X-Forwarded-Host and X-Forwarded-Proto from proxies you name. whk runs on your machine, so the proxy to trust is the loopback address:
bootstrap/app.php
->withMiddleware(function (Middleware $middleware): void {
// whk share connects from this machine, and sets only these headers
$middleware->trustProxies(
at: ['127.0.0.1', '::1'],
headers: Request::HEADER_X_FORWARDED_FOR
| Request::HEADER_X_FORWARDED_HOST
| Request::HEADER_X_FORWARDED_PROTO,
);
})With that, generated URLs read https://<name>.sharehooks.cc/.... Request is Illuminate\Http\Request. Listing the headers matters because Laravel otherwise also trusts X-Forwarded-Port and X-Forwarded-Prefix, which the link passes through from the visitor unchanged. The docs also allow trustProxies(at: '*'), which trusts whatever connects; naming loopback is enough here.
Stop the Vite dev server and build
npm run dev (and composer run dev, which starts it for you) runs Vite on its own port and writes its address into public/hot. While that file exists, the @vite directive points script and style tags at the Vite server, such as http://localhost:5173 or http://[::1]:5173. A share is one port, so visitors get your HTML without its CSS and JavaScript.
For sharing, stop the Vite dev server (it removes public/hot on exit) and build once. @vite then loads the compiled files from public/build, served by php artisan serve on the shared port:
npm run build
php artisan serve
whk share 8000Run npm run build again after changing CSS or JavaScript. Blade and PHP changes show on the next page load without a rebuild.
APP_URL, forms and sessions
APP_URL is what the console uses to generate URLs when there is no request: Artisan commands, queued mail, scheduled jobs. Set it to the link if those need to produce working links, which is practical with a reserved name that stays the same.
Forms work as they are. Laravel 13's PreventRequestForgery middleware first looks at the browser's Sec-Fetch-Site header, which says same-origin for a form posted from the link to the link, and falls back to the CSRF token. Neither compares hosts. Session cookies are set without a domain by default, so the browser keeps them for the link; leave SESSION_DOMAIN unset, because a cookie set for another domain is dropped on the way out.
If the port is taken, php artisan serve moves to the next one (8001, and on up to ten tries), so share the port it prints.
Laravel questions
Either the Vite dev server is running, so the @vite directive points assets at localhost:5173, which visitors cannot reach, or the asset URLs were generated as http://localhost:8000 because the proxy is not trusted. Stop npm run dev, run npm run build, and add trustProxies in bootstrap/app.php.
Not for pages: during a request Laravel takes the scheme and host from the request, and with trustProxies set those are the link's. APP_URL matters for URLs generated outside a request, such as queued emails and Artisan commands.
No. By default Laravel responds to every request whatever its Host header. The trustHosts middleware is opt-in, it is skipped in the local environment, and whk share sends Host: localhost in any case.
Not from sharing itself. The CSRF middleware accepts a same-origin form post by its Sec-Fetch-Site header and otherwise checks the token from the session, and the session cookie works on the link. A 419 means the token or session is missing, for example when a cookie domain was set for another host.
Sources
The Laravel settings and messages on this page are from the official documentation and source for Laravel 13, read on 12 November 2026. What the link does to a request is from the whk share docs.
Other frameworks
Send someone your Laravel app
Sign up free, install the CLI and run whk share 8000.
No credit card