I have an express API I built to my production environment. When I call a particular endpoint to POST a new object, I get a response as if I were making a GET request. If I call my development environment url, it works fine. Any ideas on what could be causing the issue?
My Routes
// trivia routes
router.post('/trivia', trivia.create);
router.get(
'/trivia/:slug/start-round/:round',
trivia.startRound,
sms.startRound
);
router.get('/trivia/:slug/restart-round/:round', trivia.restartRound);
router.get('/trivia/:slug/end-round/:round', trivia.endRound);
router.get('/trivia/:slug/next-question', trivia.nextQuestion);
router.get('/trivia/:slug/prev-question', trivia.prevQuestion);
router.get('/trivia/:slug/validate', trivia.validate);
router.get('/trivia/:slug', trivia.one);
router.get('/trivia', function (req, res) {
res.status(400).json({ message: `looks like getting trivia with no slug` });
});
I added the last one to try to debug and confirm it was routing to a GET.
/// EDIT ///
It sounds like the issue is that the request is getting redirected via NGINX. I have the location setup as this:
location / {
proxy_pass http://127.0.0.1:8080;
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;
}
How should I modify this setup to not change the request from a POST to a GET, or is there no way around it if I'm using NGINX as a proxy?