You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello - I've noticed two issues where this dev environment package differs from the Netlify production environment in how the body of a POST call is treated.
Base64
In the production environment, event.body is a JSON string. In the dev environment, event.body is in Base64 and needs to be decoded into a JSON string. It would be helpful if the event.body was either Base64 or JSON string in both so functions work the same in both environments.
Body Types
The production environment accepts all types of body types (application/json, application/text, etc).
In the dev environment, only application/octet-stream is accepted. If a user POSTS data of say application/json, then that data is disregarded and event.body is an empty object (in Base64). This is due to line 68 of serve.js - app.use(bodyParser.raw()). When no type is specified for raw, the default is type: 'octet-stream'. Recommend a broader set of accepted types or even something like app.use(bodyParser.raw({type: () => true})) to accept all POST types.
The text was updated successfully, but these errors were encountered:
Hello - I've noticed two issues where this dev environment package differs from the Netlify production environment in how the body of a POST call is treated.
Base64
In the production environment, event.body is a JSON string. In the dev environment, event.body is in Base64 and needs to be decoded into a JSON string. It would be helpful if the event.body was either Base64 or JSON string in both so functions work the same in both environments.
Body Types
The production environment accepts all types of body types (application/json, application/text, etc).
In the dev environment, only application/octet-stream is accepted. If a user POSTS data of say application/json, then that data is disregarded and event.body is an empty object (in Base64). This is due to line 68 of serve.js - app.use(bodyParser.raw()). When no type is specified for raw, the default is type: 'octet-stream'. Recommend a broader set of accepted types or even something like app.use(bodyParser.raw({type: () => true})) to accept all POST types.
The text was updated successfully, but these errors were encountered: