Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
badb0582
Commit
badb0582
authored
9 years ago
by
Rodrigo Nascimento
Browse files
Options
Downloads
Patches
Plain Diff
Try to parse all request bodies as JSON
parent
f1c4af95
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/rocketchat-cors/cors.coffee
+20
-0
20 additions, 0 deletions
packages/rocketchat-cors/cors.coffee
with
20 additions
and
0 deletions
packages/rocketchat-cors/cors.coffee
+
20
−
0
View file @
badb0582
# 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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment