You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, Im getting below error when I tried using bitbucket.workspaces.getWorkspaces()
But im sure the issue exists in all the API calls.
Here is the error message
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.bitbucket.org/2.0/workspaces?pagelen=100.
(Reason: header ‘user-agent’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response)
It doesn't look like this is compatible with browsers. I get the same error in Safari as well.
Chrome is being smart and stripping/ignoring to send this header in the request.
So the code works in Chrome but not in other browsers.
Further more I tried to use plain fetch APIs on browser to see if this is an issue is on bitbucket API side.
Using plain Fetch API works but using the library to make the same APi call doesn't work.
I'm attaching the comparison of fetch requests made by the library vs regular here. Hope this helps!
Hi, Im getting below error when I tried using
bitbucket.workspaces.getWorkspaces()
But im sure the issue exists in all the API calls.
Here is the error message
Upon looking up the code it seems like you are explicitly adding user-agent header to the request.
https://github.com/MunifTanjim/node-bitbucket/blob/master/src/endpoint/defaults.ts#L11
It doesn't look like this is compatible with browsers. I get the same error in Safari as well.
Chrome is being smart and stripping/ignoring to send this header in the request.
So the code works in Chrome but not in other browsers.
Further more I tried to use plain fetch APIs on browser to see if this is an issue is on bitbucket API side.
Using plain Fetch API works but using the library to make the same APi call doesn't work.
I'm attaching the comparison of fetch requests made by the library vs regular here. Hope this helps!
The fetch API call im using- (THIS WORKS)
VS
The network call made by the library- (THIS DOESNT WORK)
Is there a way to override these headers on our side?? Like a
headers
parameter we can pass to the API functions??Let me know thanks!!
The text was updated successfully, but these errors were encountered: