[英]Browser-sync don't reload HTML page automatically, need to manually reload the page
[英]Browser-sync - proxy a domain gets HTTP error 403 - you don't have authorization to view this page
我使用 NodeJS 模块 browser-sync 运行 gulp 任务,如下所示。
=== 文件 gulpfile.js ===
let browserSync = require('browser-sync').create(); gulp.task('browser-sync', function(){ browserSync.init( { open: true, injectChanges: true, proxy: 'https://generalgulp.devsunset', host: '192.168.1.76', serveStatic: ['.'], https: { key: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.key', cert: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.crt' } }); });
=== ===
我的本地项目信息如下(我使用最新到当前发布日期):
我运行浏览器同步任务。 output 看起来不错。
==>
使用 gulpfile C:\WebProjects\GeneralGulp\gulpfile.js
[Browsersync] 开始“浏览器同步”...
[Browsersync] 代理: https://generalgulp.devsunset
访问网址:
本地:https://localhost:3000
用户界面:http://localhost:3001
UI 外部:http://localhost:3001
==>
我可以从本地和外部地址访问该站点。
但是,当我尝试使用代理域( https://generalgulp.devsunset )访问本地资源时,它会得到 HTTP 403:
对 <my_custom_domain> 的访问被拒绝。 您无权查看此页面
我想在运行我的 gulp “浏览器同步”任务时,它会将自定义域转换为 https://localhost:3000 或https ://300D807BADE5Z://3。
我完全按照https://browsersync.io/docs的文档。 我也尝试了所有我能找到的解决方案。 这些解决方案将我引向了我在开始时编写的 gulp 任务。
如果您能建议我进一步解决为什么我的浏览器同步无法“代理”我的域,我将不胜感激? 我的 Gulp 任务中是否缺少任何参数?
谢谢 !
我已经修改了“代理”参数,如下所示,当我使用给定端口访问代理域时它可以工作:(对于我的情况是 http(s)://generalgulp.devsunset:3000 )
`gulp.task('browser-sync', function(){
browserSync.init( {
open: true,
injectChanges: true,
proxy: 'generalgulp.devsunset',
host: '192.168.1.76',
serveStatic: ['.'],
https: {
key: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.key',
cert: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.crt'
}
});
}); `
这是关于当前问题 scope 的临时可接受的解决方案。
但是,我期望浏览器同步会将流量从自定义域( http(s)://generalgulp.devsunset )自动转发到:( http://192.168.1.76:3000 )。
浏览器同步是否允许用户这样做?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.