iriscouch / browser-request

Browser library compatible with Node.js request package
Apache License 2.0
360 stars 102 forks source link

Request works in Chrome, fails in Firefox with "CORS request rejected" error #56

Closed misterfresh closed 9 years ago

misterfresh commented 9 years ago

In Chrome the following code works. In Firefox I get the error : Error: CORS request rejected With the code :

use strict';
var request =require('browser-request');
var url = 'http://docs.google.com/spreadsheets/export?id=1-on_GfmvaEcOk7HcWfKb8B6KFRv166RkLN2YmDEtDn4&exportFormat=csv';
request(url, function (error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log('success fetch');
        console.log(response.statusCode);
        console.log(body);
    }else{
        console.log(error + ' ' + response.statusCode );
    }
});
pietercolpaert commented 9 years ago

pebcak ;) http://enable-cors.org/

misterfresh commented 9 years ago

Yes. Actually I tried with jquery ajax and had exactly the same issue. So it's not a browser-request problem. http://stackoverflow.com/questions/32897921/why-does-this-cors-request-to-a-google-drive-sheet-fail-in-firefox-works-in-c