-->

咕噜连接代理不重写作品HTTPS(Grunt connect proxy rewrite not w

2019-10-21 00:34发布

我试试这个由创建一个连接代理的文章 。 几乎一切都在我的代码是相同的,但我需要调用跨https协议的东西。

connect: {
  options: {
    port: 9000,
      hostname: '0.0.0.0',
      livereload: 35729
  },
  proxies: [{
    context: ['/foo/product', '/foo/somethingelse'],
    host: 'non-https-domain.com',
    changeOrigin: true
    rewrite: {
      '^/foo': ''
    }
  },{
    context: '/productImages',
    host: 'https-domain.com',
    https: true,
    port: 443,  // just trying
    changeOrigin: true,
    rewrite: {
      '^/productImages': ''
    }
  }],
    livereload: {
    // the same like the article
  }
}

/product/somethingelse效果很好,但/productImages没有。

我需要调用它是这样的:

localhost:9000/productImages/lot/of/directory/and/finally/a/file.jpg

它应该调用

https://https-domain.com/lot/of/directory/and/finally/a/file.jpg

点是,没有/productImages 。 但替换从来没有发生过。

先谢谢您的帮助!

Answer 1:

我犯了一个愚蠢的错误:只有与名字错误!

有一个/product的产品列表代理方面,和/productImages的图像。 我用正则表达式来设置这些名称。 而"^/product"将取代/productImages了。 (我把foo仅用于测试重写)



文章来源: Grunt connect proxy rewrite not works in https