0

I'm using nods js with express. I've tested it on my local machine and the page pulls up easy enough. start server with

node index.js

from my understanding I don't need to explicitly define the web.config so I haven't. I

here are my files

index.js

const http = require('http');
const fs = require('fs');
const express = require('express');
const app = express();

app.get('/', (req, res) => {
   res.send('Hello World')
})

app.get('/api/courses', (req, res) => {
  res.send([1,2,3])
})

app.listen(3000, () => console.log('listening'))

package.json

{
  "name": "geoscavenge",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://geoscavenge.scm.azurewebsites.net:443/geoscavenge.git"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1"
  }
}
  • If my solution helps you, could you please mark my answer as [accepted](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), tks~ – Jason Pan Sep 28 '20 at 06:20

1 Answers1

0

This problem is generally caused by the lack of web.config.

Solution:

  1. Deploy the webapp in the Linux environment.

  2. Still use the windows environment, manually add the web.config file, you can refer to https://github.com/Azure-Samples/nodejs-docs-hello-world/blob/master/web.config

  3. The easiest way is to use git for deployment. In git deployment, git will automatically create a web.config file.

enter image description here

enter image description here

Jason Pan
  • 15,263
  • 1
  • 14
  • 29