我已经在我的本地机器上设置了一个 angular4/node 应用程序,我可以ng serve并且npm start应用程序很好。我在 azure 上创建了一个 Web 应用程序,并使用John Papa 的指南将其部署到 azure。然而; 当我使用 chrome 访问该站点时,我的 index.html 没有提供,并且我得到了 404。
我什Application Settings -> Default Documents至将我的所有文档都删除了,只列出了列表index.html,没有别的。
然而;当我访问myapp.azurewebsites.com/index.html该网站时呈现。当我访问myapp.azurewebsites.com该网站是不是。
我错过了什么?
const express = require('express');
const path = require('path');
const root = './dist';
const app = express();
app.use(express.static(root));
console.log(`server ${root}`);
app.get('*', (req, res) => {
res.sendFile(`index.html`);
});
const port = process.env.PORT || '3000';
app.listen(port, () => console.log(`API running on localhost:${port}`)); …Run Code Online (Sandbox Code Playgroud)