我的網站需要呼叫不同的API,所以我在 proxy.config.json 這樣設定
{
"/api/": {
"target": "https://localhost:5001",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
},
"/wapi/": {
"target": "https://localhost:8009",
"secure": false,
"logLevel": "debug",
"changeOrigin": true,
"pathRewrite": {
"^/wapi/": "/api/"
}
}
}
開發環境都沒問題。但是,要deploy到 IIS要怎麼做? 用 URL Rewite 嗎?
我自已試了2天,但都試不成功。
貼上我的 web.config 部份內容,請大家指教
<rewrite>
<rules>
<rule name="Redirect to port 8009" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{URL}" pattern="(.*)(:\d{2,4})\/(wapi)(.*)" />
</conditions>
<action type="Rewrite" url="{C:1}:8009/api:{C4}" appendQueryString="true" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>