POST request turned into GET requests

I have a simple NodeJS server that has two POST routes. When I make POST requests from Postman, I see in the logs that the requests come through as GET requests to my deployed Fly application. However, the same requests work fine when running my app locally.

I’m new to Fly and I’m hoping I’m just missing something simple, any help would be appreciated.

Hey! It’s hard to tell what could be happening without seeing the code or setup, what does your dockerfile and fly.toml file look like?

I’m currently having the same issue. Did you manage to solve it eventually?

That’s very weird.

If you can reproduce the issue reliably, can you try with this header: flyio-debug: doit and respond here with the fly-request-id header. We can then look up a trace and possibly figure out what’s happening.

2 Likes

I have the same error with an axum app, the post request from Postman is turned into a get request, but everything work fine locally.
The fly-request-id is 01GTZWDZ13GVYH7W6CVCNAXXPH-cdg

That was a Postman error. I forgotten the “https://” at the begining of the url and the request returned a 301 that redirected to the location with https, but posman follow every redirect with a get

2 Likes

Thanks for this! Same thing happened for me using Retrofit and Insomnia.

I had a similar issue with SSR and force_https = true in my fly.toml file. When server rendering my app I would pass the current URL from the request. The protocol of the request URL seems to always be http. My app will make fetch requests while server rendering. Fly’s reverse proxy would redirect these to https turning my POST requests into GET requests. The solution was to use the X-Forwarded-Proto header to set the correct protocol before handing the URL to my app.

const url = new URL(context.req.url);
url.protocol = context.req.header("X-Forwarded-Proto") ?? "http";
console.log(url.href);

This was pretty hard to debug and likely tripping up other folks.