yakovkhalinsky / backblaze-b2

Node.js Library for the Backblaze B2 Storage Service
MIT License
191 stars 59 forks source link

Blocked by CORS policy #104

Closed code-504 closed 1 year ago

code-504 commented 3 years ago

I put the keys in the app and also in Backblaze bucket i configure cors with all origins and in google console:

Access to XMLHttpRequest at 'https://api.backblazeb2.com/b2api/v2/b2_authorize_account' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

pjatx commented 3 years ago

I'm also experiencing this issue

code-504 commented 3 years ago

Use this API in front end doesn't work, is in the back end. I think that one solution is creating funtions in a server like node js funtions and return the data to your front end with JavaScript.

pjatx commented 3 years ago

@code-504 yeah makes sense - weird because it was working fine for a day or so and then it stopped. think it's really because the backblaze API doesn't return the correct headers in the preflight API calls which seems by design.

Easiest workaround would be a serverless function I think

code-504 commented 3 years ago

@pjatx BackBlaze never worked for me on the front end. It's weird because once I saw an example with BackBlaze with JavaScript (I can't remember where from) and it only used JavaScript on the front-end and it worked and also what you comment, BackBlaze API doesn't return the correct headers. The documentation about BackBlaze API is very poor.

mattwelke commented 1 year ago

@code-504 Maybe this was the example you saw?

(don't mind me, came here after playing with Chat GPT where it recommended using this library in a unit test I plan to write for my example)