Javascript CORS Errors

Hello,

I’m trying to do a minor integration of my Write.As blog into my personal website and I can’t get any HTTP request to succeed due to CORS. I have an example up on JSFiddle, open up the developer console and hit ‘Run’ and you should see a bunch of CORS errors.

As far as I can tell it seems that Write.As isn’t filling out the CORS headers so the browser is rejecting them. I tried working around it by using the ‘no-cors’ mode but then the responses turn into opaque ones that don’t have any data in them.

Thank you for making the API, just need this little change and I’ll be good to go!

Hi @Dar13! Thanks for finding this.

In the meantime, you could use a proxy server. I set one up on Glitch using cors-anywhere, a reliable cors proxy library. All you do is prepend the proxy url to the request url. Check out a fork of your JSFiddle example with the proxy here. It should return a 200 response in the console. Feel free to use that proxy url on your website.

Hope that helps!

2 Likes