I have a node.js server api app that is not working after being deployed to azure.

It initially relies on google.api to get the data and after that stores the data in an array and sends it to client by responding to express get calls.

Initially I used:

const express = require('express'); const app = express(); const cors = require("cors"); const _ = require("lodash"); const port = 30000; app.use(cors());

which worked well enough on localhost.

For deployment, after following a tutorial I changed that to:

const express = require('express'); const app = express(); const cors = require("cors"); const _ = require("lodash"); const port = process.env.PORT || 80; var http = require('http'); app.use(cors()); var server = http.createServer(app); server.listen(port, function () { });

which did not work and finally:

const express = require('express'); const app = express(); const _ = require("lodash"); const port = process.env.PORT || 80; var login = require('./routes/login'); ... app.use('/login', login); ... module.exports = app;

and created a new folder for the get commands, as is done here https://github.com/Azure-Samples/app-service-web-nodejs-get-started/blob/master/app.js.

Nothing seems to work and I continue to get the error:

GET http://nameofsite/login 404 (Not Found) XMLHttpRequest cannot load nameofsite/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'nameofclient' is therefore not allowed access. The response had HTTP status code 404.

I have tried including the cors header as well as adding the client site to cors allowed origins in the azure portal but it makes no difference. Can anyone help with this issue or provide info on how to correctly format a node.js server using info from a google sheets document?