When I make requests via the latter URL I can see in my Heroku logs that the requests are coming through and they all have 200 statuses, so it looks like the request gets successfully redirected to the Heroku API but then something goes wrong on the way back from Heroku to Netlify. This is causing my app to be broken so any help would be really appreciated. Thanks!
I’m currently looking at this. I wonder if there’s an issue with the splat redirect no passing through query parameters. When you hit the Heroku endpoint without a query param it renders a 400… so it’s possible that Netlify’s middle-man rewriting is spitting back a 502 to you if Heroku is sending a 400 on the other end. I know that functionality is documented here but I haven’t seen much calling out the positive or negative use cases of query parameters
That’s my first thought, anyway. Going to keep poking around and see what I can find
–
Jon
EDIT: actually, upon hitting the API pass-through from CLI, I’m noting the 502 being:
HTTP/1.1 502 Invalid HTTP Response
which smells a lot like the underlying service responded with a bad HTTP code. Still not certain the query parameters are for sure a factor, but definitely feels like Heroku isn’t sending back a 200!
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Wed, 10 Jun 2020 14:49:27 GMT
Server: Cowboy
+-----------------------------------------+
| NOTE: binary data not shown in terminal |
+-----------------------------------------+
which makes me think perhaps the API isn’t actually sending back stringified JSON (which is what application/json MIME type should imply) but actual binary data representing maybe the javascript object itself from your API.
Could you share some of that code? This could definitely be causing your issue.
Hm that is very odd. I am most definitely stringifying my JSON, I’m not trying to send unstringified JS objects over the wire - I’m not even using a Node app, it’s an F# app that requires me to stringify all responses.
What CLI are you using to make that request that returns binary data? Making a request with cURL just returns the regular stringified JSON just like I get in the browser.
I could share my code but it’s a pretty enormous web app so not sure which parts would be relevant. It’s certainly not a Node app putting an un-stringified JavaScript object in the response if that’s what you’re thinking. But also I haven’t changed anything about how the response is sent or serialised. This just started happening suddenly without any meaningful changes in my code.
Actually I wonder if the problem could be that the response is gzip encoded… That could explain why you’re seeing only binary data in the CLI you’re using, if that CLI isn’t aware of gzip encoded responses, unlike the browser and cURL.
If that is the cause though then:
Why is Netlify trying to decode my API response instead of just passing it through as is?
What changed to make this suddenly break when it was working perfectly before?
I don’t know that we are trying to decode the response - I see a connection error (from our CDN node to heroku) in our internal logs. While there was an outage at heroku today on this topic: Heroku Status - your logs are older and seem unrelated (though the symptoms were the same at the time).
I’ve put the details about this into the meeting agenda for a pairing our Support team will have with our traffic & delivery team next week to get their input, since there was a clear switchover after the 4th of June in our internal logs from working to not.
We’ll follow up with you after we get a chance to talk with them!
Unfortunately beyond getting a bug filed our team did not get to the bottom of it. Sorry I don’t have better news for you today, but I will follow up here in case we do get a fix for that bug.