I made a simple nodejs web app and upload to Azure,but it always returns 403 forbidden.
Request URL: https://wemwebconsole.azurewebsites.net/
Request Method: GET
Status Code: 403 Forbidden
How could I fix this issue? Is there anything wrong?
The files tree is as listed.
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1> <%= temp %></h1>
</body>
</html>
server.js
var express = require('express');
var app = express();
var path = require('path');
var ejs = require('ejs');
var serveIndex = function(req, res, next) {
next();
};
//app.use(express.static(path.join(__dirname, 'dist')));
serveIndex = function(req, res, next) {
function renderIndex() {
var data = {
hhh:'hahaha'
};
ejs.renderFile( path.resolve('dist/index.html'), data, 'utf8', function (err, str) {
if (err === null) {
res.status(200).end(str);
}
else {
next(err);
}
});
};
renderIndex()
}
app.get('*', serveIndex);
app.listen(process.env.PORT || 443);
package.json
{
"name": "app",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "",
"dev": "",
"start": "node server.js"
},
"dependencies": {
"ejs": "2.4.1",
"express": "~4.13.4"
},
}
Update: Adding web.config does not work:
<configuration>
<system.webServer>
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
</system.webServer>