yakovkhalinsky/backblaze-b2

Blocked by CORS policy

code-504 opened this issue · 5 comments

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

I'm also experiencing this issue

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

@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

@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.

@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)