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
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