【发布时间】:2021-11-19 00:39:37
【问题描述】:
我使用 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'
}
});
});
=== ===
我的本地项目信息如下(我使用最新到当前发布日期):
- 节点版本:17.1.0
- NPM 版本:8.1.3
- 吞咽:4.0.2
- NPM 模块浏览器同步:2.27.7
我运行浏览器同步任务。输出看起来不错。
==>
使用 gulpfile C:\WebProjects\GeneralGulp\gulpfile.js
[Browsersync] 开始“浏览器同步”...
[Browsersync] 代理:https://generalgulp.devsunset
访问网址:
本地:https://localhost:3000
用户界面:http://localhost:3001
UI 外部:http://localhost:3001
==>
- 我已经将此域的 SSL 证书添加到受信任的根目录。我也有来自该域的 DNS 记录(https://generalgulp.devsunset)-IP 地址(127.0.0.1 和 192.168.1.76)
我可以从本地和外部地址访问该站点。
但是,当我尝试使用代理域(https://generalgulp.devsunset ) ,它得到一个 HTTP 403 :
对
的访问被拒绝。您无权 查看此页面
我想在运行我的 gulp“浏览器同步”任务时,它会将自定义域转换为 https://localhost:3000 或 https://192.168.1.76:3000
我完全按照https://browsersync.io/docs 的文档。我也尝试了所有我能找到的解决方案。这些解决方案让我完成了我一开始写的 gulp 任务。
如果您能建议我进一步解决为什么我的浏览器同步无法“代理”我的域,我将不胜感激?我的 Gulp 任务中是否缺少任何参数?
谢谢!
【问题讨论】:
标签: javascript proxy gulp node-modules browser-sync