CORS and the file service


#1

I am creating an angular application, and I want to use the preconfigured ‘files’ service to store some .pdf files.

I created a folder ‘pdfs’ and a .pdf file ‘testpdf1.pdf’, and placed them into the ‘files’ folder like so: files/pdfs/testpdf1.pdf.

Then I tried to GET testPdf1.pdf in angular like so

$http({
    method: 'GET',
    url: 'http://someUrl.com/api/v2/files/pdfs/testpdf1.pdf?download=false',
    headers: {
        'X-DreamFactory-Api-Key': 'theApiKey',
        'X-DreamFactory-Session-Token': 'theToken'
    }
}).then(function(response){
    console.log('Success');
    console.log(response);
}, function(err){
    console.log('Failure');
    console.log(err);
});

For some reason this causes a CORS error. Which is peculiar because

  1. I have configured the CORS settings to accept everything
  2. I have already successfully communicated to this API without getting a CORS error
  3. I can perform the same API call in API Docs and Postman
  4. I can do a GET files/pdfs/ without problem

What could be the problem, and what could be done to fix it?


#2

Known bug in older version of DF. Are you up to date? If not, I recommend upgrading. http://wiki.dreamfactory.com/DreamFactory/Upgrades