我们在Microsoft Azure中创建了一个Linux Web App。该应用程序是用React(HTML和Javascript)静态编写的。我们将代码复制到了wwwroot文件夹中,但是该应用程序仅仅显示hostingstart.html,并且当我们尝试获取页面index.html时出现以下错误:
Cannot GET /index.html
我们尝试在GitHub(https://github.com/Azure-Samples/html-docs-hello-world)中使用Azure的示例,但错误是相同的。网址是这样的:https://consoleadmin.azurewebsites.net/index.html
上周,应用程序运行正常。
我们忘了做什么?
我试图在Azure Web Appp上运行一个非常简单的node.js服务器来提供单页面应用程序.服务器将提供静态页面,并且总是服务器'index.html'用于页面请求,因为所有路由都在客户端完成.
所有工作都完全在本地完成,但在部署到Azure时,任何页面请求都会导致"您要查找的资源已被删除...",这表明节点服务器未被命中.
我使用Koa作为服务器,server.js在这里;
var Koa = require('koa');
var convert = require('koa-convert');
var helmet = require('koa-helmet');
var historyApiFallback = require('koa-connect-history-api-fallback');
var serve = require('koa-static');
var app = new Koa();
// This rewrites all routes requests to the root /index.html file
// (ignoring file requests). If you want to implement isomorphic
// rendering, you'll want to remove this middleware.
app.use(convert(historyApiFallback({
verbose: false
})));
// Serving ~/dist by default. Ideally these files should be served by
// the web server and …Run Code Online (Sandbox Code Playgroud)