Grunt connect proxy rewrite not works in https

随声附和 提交于 2019-12-11 10:16:28

问题


I try to create a connect proxy by this article. Almost everything is the same in my code, but I need to call something across https protocol.

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
  }
}

The /product and the /somethingelse works well, but the /productImages not.

I need to call it like this:

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

and it should call the

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

the point is that without /productImages. But the replace never happened.

Thanks in advance for the help!


回答1:


I made a stupid mistake: There is only error with the names!

There is a /product proxy context for the product list, and a /productImages for the images. I use regex to set these names. And the "^/product" will replace the /productImages too. (I put the foo only for testing the rewrite)



来源:https://stackoverflow.com/questions/25996668/grunt-connect-proxy-rewrite-not-works-in-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!