-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support for setting withCredential true/false #257
Comments
I'm a bit confused as to what you are asking for. The |
I want to make cross domain request with the parameter withcredential false. Thanks.
|
There currently is not an option to set |
Thanks, but any plans for which release this issue will be resolved? |
Can you help me understand your use case? That might bump this up in priority. |
if server response header is having the parameter Access-Control-Allow-Origin as * then it doesn't need to have withCredentials true. withCredential parameter required only when Access-Control-Allow-Origin in response header is a specific IP/HOST. |
Sure, it is not required, but it also doesn't hurt anything. |
Closing for now. If you can provide me with a use case where you need |
Actually, Chrome will refuse to deliver the response to the calling JS: |
I'm new to this kind of CORS and CSRF issues so I might not understand correctly, but according to this:
It sounds like I don't want |
@hgwood It also requires |
@brycekahle It does. Thank you for answering. I did not meant to imply that SockJS does something that is a security liability, just that according to this quote, it implicitly does something that the application developer should explicitly choose to do. Also you are assuming that the client is trusting the server. What if I'm developing a client that connects to 3rd party servers (public APIs)? Then SockJS forces me to accept cookies from these parties, doesn't it? (Again, I'm learning here.) If I'm developing a client-server pair, then it forces my server to have Wouldn't that be 2 things a developer would like to control? However I don't know why SockJS does it so there might be an advantage here that I don't understand :). The code comes with a comment saying: // Mozilla docs says https://developer.mozilla.org/en/XMLHttpRequest :
// "This never affects same-site requests."
this.xhr.withCredentials = 'true'; But then this line is only executed for cross-site requests, so I'm a bit confused. |
+1 for re-opening and fixing this issue. My Node.js server is running on a different domain than my localhost development setup. To allow API requests I'm using SockJS and the sockjsServer.installHandlers(server, { prefix : '/sockjs' });
app.use(cors()); This leads to the following error in the browser (Chrome):
I've found 2 ways to work around it. The first is on the server side: app.use(cors({ origin : true, credentials : true })); This may not be desirable or possible depending on the server setup. The second way is to monkey-patch SockJS on the client side, taking advantage of the fact that import AbstractXHRObject from 'sockjs-client/lib/transport/browser/abstract-xhr';
const _start = AbstractXHRObject.prototype._start;
AbstractXHRObject.prototype._start = function(method, url, payload, opts) {
if (!opts) {
opts = { noCredentials : true };
}
return _start.call(this, method, url, payload, opts);
}; |
@nylen What version of the |
Latest - I still need to set up CORS for other things on this server (some JSON endpoints). |
@nylen you shouldn't apply the |
redmountainmakers/kilntroller-server@e482663 - that makes sense, and works without the hacks. Thanks! |
Hi this is the first time I use your biblioteque with angular and spring. the client and the server are running on two different domains. when running the client I am confronted with an error on chrome that says:
I wanted to know if the problem was solved. thank you |
Hi @modoulo, I think if you can set |
@nylen I already did it but it still does not work.
as indicate in this url #416 |
@nylen 's way is pretty good. Or we can set nginx header |
Is there any working solution for this, it took away 3 hours to get around this problem, and still not getting closer. Why is it so hard to make this property configurable? |
What would be a proper way to work around mentioned problem in case when I'm connecting to server I don't control and it always answering with
So Chrome is complaining that |
+1 for re-opening and fixing this issue. |
this issue has been opened so long and not solved yet? looking forward ... |
Nice,thank you! ——weihong
|
+1, please fix this |
still an issue for us |
Nice,thank you! ——weihong
|
I can find that noCredentials flag with option does set withCredential true/false but it doesn't work.
Are there any other ways or documentation will help me to set the parameter noCredentials flag true/false with request.
The text was updated successfully, but these errors were encountered: