Thanks@parastoo, it works now. I have to start the development server like this (2 different terminal tabs):
vite --host=HOST_IP php artisan serve --host=HOST_IP
Then connect your mobile device (connected to your WiFi) to:
http://HOST_IP:PORT
HOST_IPcan be seen in the terminal when runningvite --host
PORTcan be configured by adding--port=8000
to the artisan command.
No need to add any entries invite.config.js
.
I'm using inertia, a holistic approach to developing applications with frontend frameworks likevue
andlaravel
as backend. I'm trying to connect a mobile device from my network to my development server usingvite
andphp server
:
vite
php artisan serve
This site is served byhttp://localhost:8000
. From How to expose "host" for display by external devices? #3396 I read that you can do something like this:
vite --host
This should expose your network:
vite v2.9.13 dev server running at: > Local: http://localhost:3000/ > Network: http://192.xxxxxxxxx:3000/ ready in 419ms.
But when I try to connect to the network url on my phone,this page
cannot be found. I also tried connecting to port8000
, which saysThis site is unreachable
.
Is there any way to make it work?
Your php terminal is running onlocalhost:8000
So you can run php artisanserve on the host.
You should connect to the same network and then check your local IP and serve your Laravel project via:
**You should disable the firewall**
updated
Add this configuration to your
vite.config.js
fileFor example, this is my configuration file:
Then run this command and add the hosts you are serving with Laravel:
These commands should be run with the same host: