cristie09
cristie09

Reputation: 331

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.

Upvotes: 1

Views: 335

Answers (2)

Don F.
Don F.

Reputation: 123

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.

Upvotes: 1

Cam Gallucci
Cam Gallucci

Reputation: 11

seems like in the live server you made a get request, not post.

Upvotes: 1

Related Questions