Skip to content

Commit

Permalink
Merge pull request #218 from bshamblen/master
Browse files Browse the repository at this point in the history
Add option to disable CORS headers
  • Loading branch information
brycekahle committed Oct 12, 2017
2 parents 5dae15a + 81b5683 commit 1e86fe5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -156,6 +156,13 @@ Where `options` is a hash which can contain:
connection have not been seen for a while. This delay is configured
by this setting. By default the `close` event will be emitted when a
receiving connection wasn't seen for 5 seconds. </dd>

<dt>disable_cors (boolean)</dt>
<dd>Enabling this option will prevent
<a href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS</a>
headers from being included in the HTTP response. Can be used when the
sockjs client is known to be connecting from the same origin as the
sockjs server.</dd>
</dl>


Expand Down
2 changes: 1 addition & 1 deletion src/chunking-test.coffee
Expand Up @@ -33,7 +33,7 @@ exports.app =
info: (req, res, _) ->
info = {
websocket: @options.websocket,
origins: ['*:*'],
origins: ['*:*'] unless @options.disable_cors,
cookie_needed: not not @options.jsessionid,
entropy: utils.random32(),
}
Expand Down
3 changes: 3 additions & 0 deletions src/trans-xhr.coffee
Expand Up @@ -57,6 +57,9 @@ exports.app =
return true

xhr_cors: (req, res, content) ->
if @options.disable_cors
return content

if !req.headers['origin']
origin = '*'
else
Expand Down

0 comments on commit 1e86fe5

Please sign in to comment.