vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.12k stars 6.14k forks source link

Vite doesn't load asset when running with host flag in Laravel app #12213

Closed yuxxeun closed 1 year ago

yuxxeun commented 1 year ago

Describe the bug

I just build an app with Laravel 9.x with vite v3.0 for module bundler. Whenever i run with normal mode: php artisan serve for running laravel and npm run dev for running vite, everythings goes to normal.

But, when i want to share this app through ip addresse and i run command php artisan serve --host=ip_address --port=8000 & npm run dev --host my css & javascript not loaded and the view automatically broken

I have try several command but the assets still not loaded

Reproduction

http:/localhost:8000

Steps to reproduce

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (4) x64 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz
    Memory: 87.06 MB / 3.73 GB
Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (110.0.1587.57)
    Internet Explorer: 11.0.22000.120
npmPackages:
    vite: ^3.0.0 => 3.2.4

Used Package Manager

npm

Logs

$ npm run build --debug

build vite build

vite v3.2.4 building for production... ✓ 49 modules transformed. public/build/assets/SpaceMono-Regular.61a4bcc4.woff2 31.58 KiB public/build/assets/BasementGrotesque-Black.d2ea0954.woff2 17.36 KiB public/build/assets/Silk-Serif-Black.91331f3b.woff2 20.76 KiB public/build/assets/Neue-Montreal-Regular-400.8b139cb2.woff2 18.02 KiB public/build/assets/BasementGrotesque-Display.892b4f03.woff2 10.24 KiB public/build/manifest.json 1.13 KiB public/build/assets/app.9423bfe9.css 42.87 KiB / gzip: 7.65 KiB public/build/assets/app.9e5992c8.js

Validations

sapphi-red commented 1 year ago

This needs to be investigated on laravel side first. There aren't any issues reported related to this to Vite. I guess it's something wrong with your configuration or laravel sends a special request to Vite.

yuxxeun commented 1 year ago

This needs to be investigated on laravel side first. There aren't any issues reported related to this to Vite. I guess it's something wrong with your configuration or laravel sends a special request to Vite.

Yes, it was solved with the command npm run dev -- --host 10.10.x.x --port 3000