【问题标题】:How to use browsersync with an apache vhost on same port?如何在同一端口上将 browsersync 与 apache vhost 一起使用?
【发布时间】:2020-03-27 14:30:04
【问题描述】:

我知道在 SO 和 GitHub 上有很多类似的问题,但在我的情况下都没有。

我需要一个项目来使用 gulp + browsersync 和 apache vhost(使用 MAMP PRO 5.5 创建)。

Gulp 正在工作(它完成了我需要的所有任务)。 Browsersync 已设置,但它会在与 MAMP 使用的端口不同的端口上打开我的网站。我已经使用默认端口和 Mamp 默认端口进行了测试。 Browsersync 仍然使用正确的 url 但不是正确的端口打开网站。

我知道我不能使用相同的端口,但我该如何设置 Browsersync ?

这是我的 gulp 相关部分:

gulp.task('browser-sync', ['sass', 'scripts'], function () {
    browserSync.init({
        open: 'external',
        host: 'my-domain.dev',
        proxy: 'my-domain.dev',
        https: {
            key: "/Users/path-to-custom-certificate/my-domain.dev.key",
            cert: "/Users/path-to-custom-certificate/my-domain.dev.crt"
        },
        //port: 443, // If I try same port as MAMP, Browsersync increments this port ex 444
        browser: "google chrome"

    });
});

Mybe 可以在 APACHE 中配置一些东西吗?

【问题讨论】:

    标签: macos apache gulp mamp browser-sync


    【解决方案1】:

    我犹豫是否要删除我的问题,但万一它可以帮助:

    最后,看来我的 Browsersync 代码是正确的。当我运行 gulp 时,它会使用 Browsersync 默认端口打开错误的 url:

    https://my-domain.dev:3000
    

    但是当我打开在 apache 中设置的正确 url (my-domain.dev) 时,Browsersync 已连接并重新加载该页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 2016-08-29
      • 2017-02-07
      • 2013-03-09
      • 2018-01-19
      • 1970-01-01
      相关资源
      最近更新 更多