redwoodjs / redwoodjs-com-archive

Public website for RedwoodJS
https://redwoodjs.com
129 stars 156 forks source link

docs: Function/Webhook examples use content-type header to avoid error decoding lambda response #935

Closed dthyresson closed 2 years ago

dthyresson commented 2 years ago

As part of the issue noted in Discourse https://community.redwoodjs.com/t/help-webhook-works-in-dev-but-not-at-netlify/2668/2 realized that the Webhook examples did not include Content Type headers which could cause issues when deployed to Netlify and getting the error decoding lambda response.

As @dac09 notes:

looks like the content type on your success path is incorrect. It’s probably a good idea to be consistent and always respond with the same content type headers

e.g.

return {
    statusCode: 200,
    headers: {
      'Content-Type': 'application/json',
    },
   body: JSON.stringify({ now: Date.now()})
}

This PR adds those headers into the example code.