question

sujithreddykomma-6717 avatar image
1 Vote"
sujithreddykomma-6717 asked ·

Azure Node JS WebApp

Hi,

I have a simple Node Js Script like below. its just a simple Get Operation.

const express = require('express');

const app = express();

const port = process.env.PORT || 3000;

app.get('/', (req, res) => { res.send('Welcome to my Nodemon API!'); });

app.listen(port, () => { console.log(`Running on port ${port}`); });

I deployed it into a webapp of node 10 Runtime Stack. Now i want to access this get api. i dont have any front end pages. I just need to access my apis.

My Website Url looks like below https://XXX.azurewebsites.net.

How will i access my Get Operation with the above code?

Is it possible webapp only have the apis but not any front end pages?

azure-webapps
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Are you receiving a response when you access the / route once the app is deployed or are you seeing an error message?

0 Votes 0 · ·

Hi Aaron,

I dint receive any. it just keeps loading. After Some time, it just says page cannot be displayed.

0 Votes 0 · ·
PiyushMutha avatar image
0 Votes"
PiyushMutha answered ·

try using port number after url. https://XXX.azurewebsites.net:3000

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Piyush,

I tried it but no luck

I could actually see Log Streams like below

2020-01-27T09:25:03.308776753Z 2020-01-27T09:25:03: PM2 error: [PM2][ERROR] script not found : /home/site/wwwroot/index.js 2020-01-27T09:25:03.309636181Z 2020-01-27T09:25:03: PM2 error: script not found : /home/site/wwwroot/index.js 2020-01-27T09:25:03.320307826Z 2020-01-27T09:25:03: PM2 log: 2020-01-27T09:25:03.320350527Z ??? App name ??? id ??? version ??? mode ??? pid ??? status ??? restart ??? uptime ??? cpu ??? mem ??? user ??? watching ??? 2020-01-27T09:25:03.320364427Z 2020-01-27T09:25:03.322338491Z 2020-01-27T09:25:03: PM2 log: Use pm2 show to get more details about an app

2020-01-27T09:25:03.328430788Z 2020-01-27T09:25:03: PM2 log: [--no-daemon] Exit on target PM2 exit pid=52

0 Votes 0 · ·
TechGropse-7722 avatar image
0 Votes"
TechGropse-7722 answered ·

Mobile Application Development Companies USA Uses Twelve factor App Methodology to plan and execute the app development process efficiently.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

sujithreddykomma-6717 avatar image
0 Votes"
sujithreddykomma-6717 answered ·

I just changed form app.js to index.js now it works

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

yes, because you are using express module. When you run app.js express look for app.html that not exists, but index.html is part of express module

0 Votes 0 · ·