Welcome! Log In Create A New Profile

Advanced

Multiple Location Blocks not working

Posted by hsdmedia 
Multiple Location Blocks not working
February 15, 2021 05:48AM
I'm struggling in a little confusion and that is I have a node server with multiple routes, like these

app.get('/checkAPI', (request, response) => {
console.log('API check requested');
response.send('API Working fine');
});
app.get('/', (request, response) => {
console.log(request.body);
response.json({ status: 'end' })
});

but the problem is that only route in my server that works is '/' this one.
even though I added multiple location blocks but it still not works

here are my location blocks

location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location /checkapi {
proxy_pass http://localhost:3000/checkAPI;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

the later location block is supposed to forward the request to '/checkapi' node route, but this doesn't
I made sure to save the file and restart the server but still it not works

What to do in this scenario ?

Regards
Ahsan
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 92
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready