Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable CORS headers #218

Merged
merged 6 commits into from Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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