无法获取index.html Azure Linux Web App [英] Cannot GET index.html Azure Linux Web App

查看:158
本文介绍了无法获取index.html Azure Linux Web App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我们在Microsoft Azure中创建了一个Linux Web App。该应用程序是使用React(html和Javascript)静态编写的。我们将代码复制到wwwroot文件夹中,但应用程序仅显示了hostingstart.html,当我们尝试获取页面index.html
时,我们遇到此错误:

无法获取/index.html 


我们尝试使用GitHub中的Azure示例(https://github.com/Azure-Samples/html-docs-hello-world)但错误是一样的。网址是这样的:https://consoleadmin.azurewebsites.net/index.html

上周应用程序运行正常。


我们忘记做某事了?

解决方案

我注意到你已经通过
修复了这个问题
在index.js,server.listen(process.env.PORT)中添加  port  并附加< span style ="font-size:10pt; font-family:Arial,sans-serif; color:#242729">
'npm init'开头,'npm start'开头'npm install --save express 代码
来自你的

SO主题
- 从线索和博客中复制信息,以便为社区带来好处:

https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-和-linux / #NodeHome


当您创建Node.js应用程序时,默认情况下,它将使用hostingstart.html作为默认文档,除非您将其配置为查找其他文件。您可以使用JavaScript
文件配置您的默认文档。在您网站的根文件夹中创建一个名为index.js的文件,并添加以下内容。



var express = require('express') ;

var server = express();

var options = {

index:'index.html'

};

server.use('/',express.static('/ home / site / wwwroot',options));

server.listen(process.env.PORT);

We created a Linux Web App in Microsoft Azure. The application is static written with React (html and Javascript). We copied the code into the wwwroot folder, but the application only showing only hostingstart.html and when we try to get page index.html we have this error:

Cannot GET /index.html

We tried with a sample of Azure in GitHub (https://github.com/Azure-Samples/html-docs-hello-world) but the error is the same. The url is this: https://consoleadmin.azurewebsites.net/index.html

Last week the application was running correctly.

We forget to do something?

解决方案

I noticed that you have fixed this issue by adding the port in the index.js, server.listen(process.env.PORT) and appended 'npm init' at the beginning and 'npm start' after 'npm install --save express in the code from your SO thread - Copied the information from the thread and blog here for benefitting the community: https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#NodeHome :

When you create a Node.js app, by default, it's going to use hostingstart.html as the default document unless you configure it to look for a different file. You can use a JavaScript file to configure your default document. Create a file called index.js in the root folder of your site and add the following content.

var express = require('express');
var server = express();
var options = {
index: 'index.html'
};
server.use('/', express.static('/home/site/wwwroot', options));
server.listen(process.env.PORT);


这篇关于无法获取index.html Azure Linux Web App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆