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

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at #59

Open
PetrShchukin opened this issue May 17, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@PetrShchukin
Copy link

PetrShchukin commented May 17, 2020

Is there a working example? I'm tying

  const bitbucket = new Bitbucket();

  bitbucket.repositories
    .list({ workspace: "MunifTanjim" })
    .then(({ data }) => console.log(data.values))
    .catch((err) => console.error(err));

but having a cors error.
"bitbucket": "^2.1.0",

@MunifTanjim
Copy link
Owner

MunifTanjim commented May 17, 2020

Are you using this from browser? Maybe Bitbucket doesn't allow cross-origin requests anymore 🤷‍♂️

I just ran your code here: https://npm.runkit.com/bitbucket and it worked alright.

@PetrShchukin
Copy link
Author

It works from npm.runkit.com... I've created react app, tried from there, but got a cors error. With an axios request and their rest api it works fine =/

@MunifTanjim
Copy link
Owner

Can you show me a minimal project with this bug?

I can use it without any problem here: https://codesandbox.io/s/bitbucket-with-cra-c5rk2

@PetrShchukin
Copy link
Author

But your example doesn't work... I'm getting 500 error, probably the original error on codesandbox is hidden

"{"name":"HTTPError","headers":{},"request":{"method":"GET","url":"https://api.bitbucket.org/2.0/repositories/MunifTanjim","headers":{"accept":"application/json","user-agent":"bitbucket.js/2.1.0"},"request":{"validate":{"role":{"enum":["admin","contributor","member","owner"],"type":"string"},"workspace":{"required":true,"type":"string"}}}},"status":500}"

@MunifTanjim
Copy link
Owner

Strange 🤔 I was working yesterday when I created that sandbox. Now it's not working anymore!

@MunifTanjim MunifTanjim added the bug Something isn't working label May 18, 2020
@MunifTanjim
Copy link
Owner

image

Now it's working again!

@PetrShchukin
Copy link
Author

Still getting a 500 error on codesandbox and cors in a react app 🤷‍♂️. I've created a react app by using 'npx create-react-app myapp', then 'yarn add bitbucket', then simply add

  const bitbucket = new Bitbucket();
  React.useEffect(() => {
    bitbucket.repositories
      .list({ workspace: "MunifTanjim" })
      .then(({ data }) => console.log(data))
      .catch(err => {
        console.error(err);
      });
  }, [bitbucket.repositories]);

to App.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants