Skip to content Skip to sidebar Skip to footer

Cors Request Working In Excel But Not In Javascript

I understand the CORS policy and since the server is not set to accept CORS requests, I should not be able to download the CSV file from a different origin. However the server seem

Solution 1:

Its because CORS is typically a browser policy, Excel doesn't care about CORS policy because Excel isn't really vulnerable to a scenario that browsers face every day (fake websites running javascript that pulls data from the real site.) If what you're doing is just a one off scenario you can disable CORS policy in your browser, but that won't work for a production website.

My advice would be to use some php in a server side script to download the CSV and then print its contents..

Something like...

<?phpecho file_get_contents('http://otherdomain.com/that_csv_file.csv');
?>

Then point your javascript url at your now 'same domain' php script.

Post a Comment for "Cors Request Working In Excel But Not In Javascript"