@vite 抽的什么疯
1. 运行环境
1). 当前使用的 Laravel 版本
Laravel Framework 9.33.0
2). 当前使用的 php/php-fpm 版本
PHP 版本:PHP 8.1.14RC1
3). 当前系统
Ubuntu 20.4, Laravel 运行于 docker 中
2. 问题描述?
在主页面中引入 @vite,最终生成的 html 代码中资源默认加了根地址 localhost:8142
resources/views/site.blade.php 代码
@vite(['resources/css/app.css', 'resources/js/app.js'])
最后生成的 html
<link rel="stylesheet" href="http://localhost:8142/build/assets/app-35ef89ab.css">
<script type="module" src="http://localhost:8142/build/assets/app-ffa2faf6.js"></script>
为什么要默认加上 localhost:8142 这是什么鬼
3. 您期望得到的结果?
<link rel="stylesheet" href="/build/assets/app-35ef89ab.css">
<script type="module" src="/build/assets/app-ffa2faf6.js"></script>
或者在哪里手动指定根路径就更好了
4. 您实际得到的结果?
<link rel="stylesheet" href="http://localhost:8142/build/assets/app-35ef89ab.css">
<script type="module" src="http://localhost:8142/build/assets/app-ffa2faf6.js"></script>
.env ASSET_URL change to
http://localhost:8142