2
將節點.js/express應用程序部署到Azure網站時,我在瀏覽器中收到「Can not GET /」錯誤。相同的應用程序在本地機器上完美運行。Azure網站+ node.js - 無法獲取/
web.config
是標準的(我只去除靜態重寫規則),所以:
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="src/server/app.js"/>
</rule>
</rules>
代碼部署在src/server/
(節點功能)和src/client/
(靜態內容)文件夾。
按照該FREB記錄在src /服務器/ apps.js是牽強,但最終出現以下錯誤被拋出:
ErrorCode The system cannot find the file specified. (0x80070002)
裏面app.js
我對靜態文件進行以下配置:
app.use(express.static('./src/client/'));
另一個解決方案是將啓動腳本從src/server /移動到wwwroot /文件夾。這隻需要修改一個文件。 –