I am trying to run a very simple node.js server on an Azure Web Appp to serve a single page application. The server will serve up static pages, and will always server 'index.html' for page requests as all the routing is done client side.
All works absolutely perfectly locally, but when deploying to Azure, any page requests result in a 'the resource you are looking for has been removed...', which suggests the node server isn't being hit.
I am using Koa as the server, and the server.js is here;
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 not the app server, but this helps to demo the
// server in production.
app.use(convert(serve(__dirname)));
app.use(helmet());
var server = app.listen(3000);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 not the app server, but this helps to demo the
// server in production.
app.use(convert(serve(__dirname)));
app.use(helmet());
var server = app.listen(3000);
I have included the package.json on the deployment as some documentation suggested that required node packages would be auto-installed (Koa etc), but it doesnt seem as though that has worked.
Any ideas?