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 3 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" target="_blank">CORS</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include the target. Let's not presume we know what the user wants.

headers from being included in the HTTP response. Can be used when the
sockjs client is know to be connecting from the same domain as the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change domain to origin?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'know' ?

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