1
我嘗試通過此article創建連接代理。在我的代碼中,幾乎所有內容都是相同的,但我需要通過https協議調用某些內容。Grunt連接代理重寫不起作用在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
。但替換從未發生過。
在此先感謝您的幫助!
是否有錯誤?您是否使用自簽名SSL證書? – mike 2014-09-23 13:49:32
沒有錯誤,只是簡單地調用了一個錯誤的url。我不使用自簽名證書。 – kree 2014-09-23 13:51:37
我不是100%肯定的,但我相信你在嘗試在本地主機上使用https時需要一個自簽名證書......它在哪裏失敗? – mike 2014-09-23 13:55:01