CORS issue with file uploading API

Highlighted
First-time Contributor

CORS issue with file uploading API

I'm posting a file to "https://upload.box.com/api/2.0/files/content" from my react application but it throws CORS error.

I added my localhost to the CORS whitelist in configuration section of my box app but that doesn't work too.

Then I deployed my frontend to live server thinking that may be box API is getting issues with local environment. I added the live url to CORS whitelist but no luck with this too.

I've already spent handsome amount of time but getting failed. Kindly assist me in this regard.

 

I shall be very grateful to you.

 

Regards

2 REPLIES 2
Highlighted
Box Employee

Re: CORS issue with file uploading API

Do the upload requests you're making include an `HTTP origin` header? 

For more information, we have a guide on best practices for CORS: https://developer.box.com/guides/best-practices/cors/

Occasional Contributor

Re: CORS issue with file uploading API

When I try to add an origin: header to my POST, it is rejected as an unsafe header.

 

What's frustrating to me is that the Box folder API is working fine, it's just the Box upload API which throws this CORS error.