Search code examples
node.jsexpresspostget

Nodejs GET and POST mixed up in live server but working in localhost


I have the following APIs, in order

router.post('/:name/insertDesign', function(req, res) {
  console.log('[API] /insertDesign { username: ' + req.params.name + ' }');


router.get('/:name/:project', excludeSpecialRoutes, function(req, res, next) {
    result = {
      username: 'anonymous',
      project: req.params.project,
      access: 'Public',
    };
  console.log('[API] /project', result);

When running the post call in localhost I got the following log:

[API] /insertDesign { username: vc }

but when running it post call in the live server the log is as follow:

[API] /project { username: 'anonymous',
  project: 'insertDesign',
  access: 'Public' }

This is very confusing, shouldn't the API call reached the code in order? The code was working fine in the live server before.. Kindly give advice how I could troubleshoot this issue.. Thank you.


Solution

  • Maybe it's your nginx if it's on the server. POST request turns into GET request

    I assumed you tried on your local machine without nginx while the server has one.