-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting status code/headers from api routes in Netlify functions does not work #414
Comments
I think the output you're seeing is from this So while it's not exactly the So this does look like an elm-pages bug to me. Unfortunately, it's in elm-pages itself (in @dillonkearns , is the fix to change the logic in |
I've spent a few hours, following the code to the places where these values come from. To me, it looks like there is a lot of type confusion going on - not only in Javascript, but also on the Elm side. I imagine this is mainly a result of the v2->v3 transition, just making things work for now. A "proper" fix would likely involve just cleaning these things up. The main "offender" related to this issue is probably that This looks like a bigger refactor waiting to happen, so for now, I've just made a pull request for the change in |
fix #414: use the statusCode and headers fields from the response.body instead of the response.
I've tried setting a custom Content-Type header to add ActivityPub support to my website. Mastodon (one of the most popular implementations) requires a Content-Type of
application/activity+json
to be set on the responses. Unfortunately, it seems like none of the headers sent from Elm make it out to Netlify. Further testing revealed that none of the headers nor the status code is correctly sent. Instead, the function always responds with a status code200
and aContent-Type
oftext/plain
. (Netlify's default)Since this works using
elm-pages dev
, I suspect that the problem might be in the Netlify adapter, specifically I think it might be confused about the response and body types.Here is a snippet from my Netlify logs:
From what I can tell from the code, this is the
renderResult
. To me, this looks suspiciously like the adapter then confuses the types ofbody
andrenderResult
, since both have akind
andstatusType
field, but only thebody
hasheaders
; this means that in the returned netlify response,multiValueHeaders
isundefined
! ThestatusCode
on the outer object is always 200.The text was updated successfully, but these errors were encountered: