问题描述
我尝试通过。几乎所有代码都是一样的,但我需要通过https协议来调用。
选项:{端口:9000,
主机名:'0.0.0.0',
livereload:35729
},
代理:[{
context: ['/ foo / product','/ foo / somethingelse'],
主机:'nonhttps-domain.com',
changeOrigin:true
重写:{
'^ / foo':''
}
},{
上下文:'/ productImages',
主机:'https-domain.com',
https :true,
port:443,//只是尝试
changeOrigin:true,
重写:{
'^ / productImages':''
}
}],
livereload:{
//与文章
相同}
}
$ b $ < / 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
。但是,替换从未发生。
感谢您的帮助!
我犯了一个愚蠢的错误:名称只有错误!
有一个 / product
产品列表的代理上下文以及图像的 / productImages
。我使用正则表达式来设置这些名称。并且^ / product
也会替换 / productImages
。 (我把 foo
仅用于测试重写)
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!
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)
这篇关于Grunt连接代理重写不适用于https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!