Skip to content
Snippets Groups Projects
Commit badb0582 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Try to parse all request bodies as JSON

parent f1c4af95
No related branches found
No related tags found
Loading
# Adding CORS headers so we can use CDNs for static content
# Try to parse all request bodies as JSON
WebApp.rawConnectHandlers.use (req, res, next) ->
if req._body
return next()
if req.headers['transfer-encoding'] is undefined and isNaN(req.headers['content-length'])
return next()
buf = ''
req.setEncoding('utf8')
req.on 'data', (chunk) -> buf += chunk
req.on 'end', ->
try
req.body = JSON.parse(buf)
catch err
req.body = buf
next()
WebApp.rawConnectHandlers.use (req, res, next) ->
res.setHeader("Access-Control-Allow-Origin", "*")
res.setHeader("X-Rocket-Chat-Version", VERSION)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment