When I run vite run dev --host
in my Laravel project, I get below screen on my external network URL:
My external URL is: http://192.168.1.6:5173
➜ Local: http://localhost:5173/
➜ Network: http://192.168.1.6:5173/
Project runs fine on my app URL defined in Laravel’s .env file viz. http://trip.dev
I am expecting http://192.168.1.6:5173/
to work same as http://trip.dev
I tried php artisan serve
(as suggessted in the above screen to run the local development server), but it keep showing me the same screen.
Can some one help me in this?
2
Answers
You should run
php artisan serve --port=8000
in a command prompt and runvite run dev --host
ornpm run dev
in other command prompt.now, you need to open
http://YOUR_IP_IN_NETWORK:8000
; for example if your ip is192.168.1.6
, you should openhttp://192.168.1.6:8000
.tip:
Make sure you use
@vite('...path...')
in your code to use vite.Open two different terminals and run
The port can be any available. Don’t forget to add this port to firewall or selinux permissions if you are using.
For some reason, styles and scripts were not connected. The problem is in the wrong path to them. To fix the work of included files, follow step 3
full example of what the file looks like below
vite.config.js
do not forget, now scripts and styles are connected like this on your pages