无法通过Laravel Mix与Laravel Sail合作浏览器同步
但是,每当我从应用程序加载后从应用程序中提出请求时,请求将发送到错误的URL。
以下是我的browsersync设置:
mix.browserSync({
proxy: 'localhost',
port: 8082,
injectChanges: false,
open: false,
files: [
'./public/css/*.css',
'./public/js/*.js',
'./resources/views/**/*.blade.php',
'./resources/js/**/*.vue',
'./resources/css/**/*.css',
],
})
这是我的docker-compose.yml
:
version: '3'
services:
laravel.test:
build:
context: ./docker/8.1
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
working_dir: /var/www/html
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
- "9865:22"
- "8082:8082"
- "8083:8083"
# ...
我导航到http:// localhost:8082/,并且页面加载良好,browsersync表示已连接。当我提交表格时,我会得到以下内容:
/code>,然后我什至无法连接。我还尝试了其他建议将其更改为> 127.0.0.1
,这没有区别。
I have managed to get Browsersync partially working, however, whenever I make a request from my app after the page has loaded, the request is sent to the wrong URL.
The following are my Browsersync settings:
mix.browserSync({
proxy: 'localhost',
port: 8082,
injectChanges: false,
open: false,
files: [
'./public/css/*.css',
'./public/js/*.js',
'./resources/views/**/*.blade.php',
'./resources/js/**/*.vue',
'./resources/css/**/*.css',
],
})
And here is my docker-compose.yml
:
version: '3'
services:
laravel.test:
build:
context: ./docker/8.1
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
working_dir: /var/www/html
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
- "9865:22"
- "8082:8082"
- "8083:8083"
# ...
I navigate to http://localhost:8082/ and the page loads fine and Browsersync says it's connected. When I submit my form though, I get the following:
From my understanding, this is an issue with the proxy not having the port, however, I tried changing the proxy to localhost:8082
and then I couldn't even connect anymore. I also tried other suggestions of changing it to 127.0.0.1
which made no difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过设置以下配置来解决问题:
其中8081是
app_port
在.env
文件中设置的。换句话说,浏览器需要与您的应用程序运行的端口相同。I fixed my issue by setting the following configuration:
Where 8081 is the
APP_PORT
set in the.env
file. In other words, Browsersync needs to be proxied to the same port as your app is running on.