问题
I use Laravel Homestead for my development environment, so my website is accessible on http://test.app
Now I tried to configure laravel mix to use it with VUEJS. For this, I include a JS file in one of my templates:
<script src="{{ url(mix('js/main.js'))}}"></script>
The result of this is
<script src="//localhost:8080/js/main.js"></script>
It seems so, that the localhost:8080 is hardcoded in vendor/laravel/framework/src/Illuminate/Foundation/helper.php (see https://github.com/laravel/framework/blob/e35a60f7f3ef1d75754522771f13762b3058f1b0/src/Illuminate/Foundation/helpers.php#L560)
How to fix this or how I done something wrong?
回答1:
the source you quote will only be executed in watch mode.
In this case, Laravel mix host a server on 8080 port for all your static files (css, js) so you can get the hot-reload feature, while the php files still running on your Homestead Niginx, and I don't see anything wrong with it.
it will compile to your APP_URL in production mode and if 8080 is somehow conflicting with your other service you can modify config file of Laravel Mix.
回答2:
try setting APP_URL in your .env config file
APP_URL = http://test.app
i hope it helps.
来源:https://stackoverflow.com/questions/47127503/laravel-mix-hot-reload-and-domain-name