How to enable CORS in Codepen to get Wikipedia viewer working?

How to enable CORS in Codepen to get Wikipedia viewer working?
0

#1

Hello everyone,

For my wikipedia viewer to work, I need cross-origin resource sharing enabled. In chrome, I have a plugin for this, but works normally in safari and firefox. It’s just that when I post to codepen CORS is not enabled. Is there any way to enable CORS on codepen? I’d appreciate if anyone could chime in.

Codepen link: https://codepen.io/Malekai/pen/BzJQod


Having a lot of trouble with API projects, please help me :(
#2

add &callback=? to the end of your url :slight_smile:


#3

hi fellow…

please i really need your help, am very new to this platform and i kind of dont know how to operate in here since a major in javascript.


#4

Hi, try putting this at the bottom of your JS code.

jQuery.ajaxPrefilter(function(options) { if (options.crossDomain && jQuery.support.cors) { options.url = 'https://cors-anywhere.herokuapp.com/' + options.url; } });

It works for me on the weather app, but I don’t need it now as I changed API.

I got it off stack overflow.

It works by directing your non https request via a proxy.

Hope that does it for you.

mark


#5

@Cinders-P thanks a lot for the &callback=? trick, it helped me, kind regards!