Support Topics Documentation Slack YouTube Blog

File Upload CORS Error

I have no trouble accessing the Backendless API except for sending POST requests to the Files service, for which I get the error: “XMLHttpRequest cannot load https://api.backendless.com/C855FF23-D9F5-874A-FFC4-300F60B6C300/v1/files/9C29640F-D5BF-4E0A-FFB3-5842D6E9E900/5NBQHX/Application%20Form. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://www.mydomainname.com’ is therefore not allowed access.”

I’m using AngularJS, specifically the Angular-File-Upload library (https://github.com/nervgh/angular-file-upload) via REST. I see there is no CORS header on the file upload response, like there is on the other API calls I make to login and call data etc. I have setup the origins in the Backendless UI.

Any help you could give would be much appreciated.

Below are the headers for the options and post requests:

    Request URL:https://api.backendless.com/C855FF23-D9F5-874A-FFC4-300F60B6C300/v1/files/9C29640F-D5BF-4E0A-FFB3-5842D6E9E900/5NBQHX/Application%20Form Request Method:OPTIONS Status Code:200 OK Remote Address:149.56.79.124:443 Response Headersview source Access-Control-Allow-Headers:Origin, application-id, application-type, Content-Type, secret-key, request, user-token Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT, DELETE, PATCH Access-Control-Allow-Origin:* Access-Control-Max-Age:1728000 Cache-Control:no-cache Cache-Control:: no-store, no-cache, must-revalidate, private Connection:keep-alive Content-Length:0 Date:Mon, 21 Nov 2016 07:30:31 GMT Expires:Thu, 01 Jan 1970 00:00:01 GMT Pragma:: no-cache Server:nginx/1.8.1 Request Headersview source Accept:*/* Accept-Encoding:gzip, deflate, sdch, br Accept-Language:en-US,en;q=0.8 Access-Control-Request-Headers:application-id, secret-key, user-token Access-Control-Request-Method:POST Cache-Control:no-cache Connection:keep-alive Host:api.backendless.com Origin:https://www.mydomainname.com Pragma:no-cache Referer:https://www.mydomainname.com/secure/ User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36

    Request URL:https://api.backendless.com/C855FF23-D9F5-874A-FFC4-300F60B6C300/v1/files/9C29640F-D5BF-4E0A-FFB3-5842D6E9E900/5NBQHX/Application%20Form Request Method:POST Status Code:200 OK Remote Address:149.56.79.124:443 Response Headersview source Cache-Control:no-cache Cache-Control:: no-store, no-cache, must-revalidate, private Connection:keep-alive Content-Length:150 Content-Type:application/json; charset=utf-8 Date:Mon, 21 Nov 2016 07:30:34 GMT Expires:Thu, 01 Jan 1970 00:00:01 GMT Pragma:: no-cache Server:nginx/1.8.1 Request Headersview source Accept:*/* Accept-Encoding:gzip, deflate, br Accept-Language:en-US,en;q=0.8 application-id:C855FF23-D9F5-874A-FFC4-300F60B6C300 Cache-Control:no-cache Connection:keep-alive Content-Length:121002 Content-Type:multipart/form-data; boundary=----WebKitFormBoundary8cE4EpNdqciC8zRa Host:api.backendless.com Origin:https://www.mydomainname.com Pragma:no-cache Referer:https://www.mydomainname.com/secure/ secret-key:94605679-6788-57CD-FFC4-4AE4C8EDAF00 User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36 user-token:5178DE71-5F01-9EC2-FFD3-A7A886DC8300

Hello, Leroy.
Please, provide code example with our REST API or JS API (simple curl or js) which demonstrate the problem.

What if you try loading the library which handles the upload from api.backendless.com? That means copying the library into the file system of your backendless app.