Back to articles
I thought you couldn't run Vite HMR Laravel on a remote VPS. I was wrong.
How-ToDevOps

I thought you couldn't run Vite HMR Laravel on a remote VPS. I was wrong.

via Dev.to DevOpsJervi

So here's the thing. I've been building a Laravel + Inertia + React project and deploying it on a VPS. My workflow was: npm run build php artisan serve --host 0.0.0.0 from my blog: source The problem When you run npm run dev , Vite starts a dev server and a WebSocket for HMR. By default it binds to localhost — meaning only processes on the same machine can reach it. The browser, sitting on your laptop, can't connect. But Vite has a server.host option that makes it bind to all interfaces, including the public one. And a server.hmr.host option that tells the browser where to connect for the WebSocket. That's the key piece most tutorials miss. Step 1 — update vite.config.ts Add a server block to your existing config. Everything else stays the same: import { wayfinder } from ' @laravel/vite-plugin-wayfinder ' ; import tailwindcss from ' @tailwindcss/vite ' ; import react from ' @vitejs/plugin-react ' ; import laravel from ' laravel-vite-plugin ' ; import { defineConfig } from ' vite ' ; ex

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
2 views

Related Articles