-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Cross Origin Request Blocked: User Agent on discovery fetch #13
Comments
I actually checked again and |
You need to use it right first, the See CORS made discovery from Chrome. Please reach out to gitlab support with this issue of theirs first. There's something awry with their CORS configuration when non-default user-agent is provided. This discovery mechanism works against other providers. Happy to look into it again if it turns out to be a non-gitlab specific issue. Also keep in mind, as a workaround, you can discover / obtain the metadata object any way that works for you with gitlab. |
You can also pass custom headers to all network utilizing functions. So you may just pass a Headers instance with user-agent being the navigator.userAgent which would be otherwise used by default if not defined by the library. Edit: nevermind, even when passing a user-agent that's the same as navigator.userAgent the CORS preflight request results in not allowing CORS. This is a gitlab specific issue in that their OPTIONS preflight response is not right. They possibly intentionally don't support public browser clients? Only gitlab can tell. |
Trying with other providers, they seem to run into a similar issue. So what i'll do instead is not set the user-agent header when in browser environment, this means no CORS preflight has to be done, or at least it won't trip CORS off. For the record this is an issue with the identity provider's invalid CORS configuration, not the library. It is absolutely okay to set a custom user-agent. |
Oh yes, you're right! I think the reason that it's not working in firefox, but in chromium, might be that settings the user agent is not possible in chromium? At least I read this in various sources and found an open bug for it: https://bugs.chromium.org/p/chromium/issues/detail?id=571722 Additionally when looking at my network tab, the user agent is not set to The SO answer https://stackoverflow.com/a/42815264/10764260 provided that link and also said that a custom user-agent used to be not allowed. So that might be a possible explanation why GitLab (and others) forbid it? Again, I have very little experience with web stuff. So I'm just guessing here. Edit: Why do you set user-agent in the first place? Does it have any use? |
I can confirm that your commit fixed the issue in firefox and chromium. Thanks for your quick help! |
Because we technically should be able to do so and the default fetch user-agent strings on non-browser runtimes (e.g. workers, deno, ...) are even more useless than the browser ones. |
What happened?
I'm getting CORS errors with
discoveryRequest
and GitLab. Some minimal reproducable code:I'm not a web developer, but I'm quite sure it is related to the library overriding the user-agent in
prepareHeaders
. Some minimal reproducable code without using the library:Should the user-agent really be the library? Usually it is the browser, isn't it?
Version
v1.0.3
Runtime
Browser
Runtime Details
Linux, Firefox & Chrome
Code to reproduce
Required
The text was updated successfully, but these errors were encountered: