You finally get the Laravel app onto https:// locally, reload, and the page comes up unstyled. The console says
the browser blocked http://[::1]:5173/resources/css/app.css: an https:// page may not load scripts and styles
over plain http://.
That is the whole difficulty of Laravel + Vite on HTTPS. There are two servers, PHP and Vite, and both have to speak TLS on a name the browser trusts. Here is the manual way, then the short way.
What you need: one name, one certificate, two servers
I will use shop.localhost. Browsers send .localhost names to your own computer without any DNS.
First, a local certificate authority and a certificate signed by it. A local CA tool does this in one command; with plain OpenSSL it is three:
# 1. the CA
openssl req -x509 -newkey rsa:2048 -nodes -days 825 \
-keyout ca.key -out ca.crt -subj "/CN=My Local CA"
# 2. a key and a signing request for the site
openssl req -newkey rsa:2048 -nodes \
-keyout shop.key -out shop.csr -subj "/CN=shop.localhost"
# 3. the certificate, with the name as a subjectAltName
openssl x509 -req -in shop.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
-days 397 -out shop.crt \
-extfile <(printf "subjectAltName=DNS:shop.localhost")
The subjectAltName matters: browsers ignore the common name and only match names listed there.
The browser has to trust the CA, not the site
Trust ca.crt once and every certificate it signs is accepted:
| System | Command |
|---|---|
| macOS | security add-trusted-cert -r trustRoot -k ~/Library/Keychains/login.keychain-db ca.crt |
| Windows | certutil -user -addstore Root ca.crt |
| Ubuntu / Debian | sudo cp ca.crt /usr/local/share/ca-certificates/my-local-ca.crt && sudo update-ca-certificates |
Firefox keeps its own list everywhere, and on Linux so does Chrome, so there you import ca.crt in the browser's
certificate settings as well.
Keep
ca.keyprivate. Anyone who can read it can make certificates your browser trusts.
Laravel behind a TLS proxy
php artisan serve speaks only HTTP, so something has to terminate TLS in front of it. With nginx:
server {
listen 443 ssl;
server_name shop.localhost;
ssl_certificate /path/to/shop.crt;
ssl_certificate_key /path/to/shop.key;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
}
}
Laravel now has to know it is behind a proxy, or it keeps generating http:// links. Set the address in .env:
APP_URL=https://shop.localhost
and trust the proxy in bootstrap/app.php (Laravel 11 and later):
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(at: '127.0.0.1');
})
Vite needs the same certificate
Now the part that caused the blocked stylesheet. Vite's dev server must serve HTTPS too, on the same name, and tell the hot-reload client where to connect:
// vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import fs from 'node:fs';
const host = 'shop.localhost';
export default defineConfig({
plugins: [laravel({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true })],
server: {
host,
hmr: { host },
https: {
key: fs.readFileSync('/path/to/shop.key'),
cert: fs.readFileSync('/path/to/shop.crt'),
},
},
});
Then run both servers:
php artisan serve # http://127.0.0.1:8000, behind the proxy
npm run dev # https://shop.localhost:5173
When Vite starts, the Laravel plugin writes its address to public/hot, and @vite in your Blade layout reads it.
If that file says https://shop.localhost:5173, the errors are gone. One catch: Node has to resolve shop.localhost
itself, which it does not do on Windows without a hosts entry.
The same thing from the folder
That is four moving parts, plus a vite.config.js change that every teammate needs matching paths for.
DevCatz does it without touching the project.
Choose Create New Site, pick the folder, and DevCatz detects Laravel from artisan and laravel/framework. The
site gets https://<name>.localhost, with a certificate made on demand and signed by DevCatz Local CA. You trust
that CA once, with Trust certificate authority….

PHP sites are Always on: PHP-FPM serves them as soon as they exist. Start runs only the extras, such as Vite, the queue worker and the scheduler.
The Vite part works differently from the manual setup. DevCatz serves Vite on the same origin as the site: it
points public/hot at the site's own address, and its proxy forwards asset requests and the hot-reload socket to
Vite. One name, one certificate, and no server.https block in vite.config.js.
Two servers on one origin means there is nothing left for the browser to block.
What it does not do
Out of the box the address carries a port: https://shop.localhost:8443. Dropping it is a separate, optional step,
Enable clean URLs…, which asks for your password once. On macOS and Windows, Firefox still needs the CA imported
by hand. And DevCatz does not rewrite your code: hard-coded http:// links stay yours to fix.
Try it
Clone any Laravel + Vite repository, add its folder, press Start, and open the address at the top of the site.
- Download: catzoid.com/devcatz/download, free for macOS, Windows and Linux
- Docs: Sites, domains and HTTPS and Detected stacks
- Source (GPL-3.0): github.com/catzoidhub/DevCatz
