Wikipedia Viewer: Wikipedia API & Cross-Origin Request Issues

I know this is an old thread but if people are still having trouble with this API, I wrote an article about solving this issue using CORS instead of JSONP Wikipedia Viewer: Wikipedia API & Cross-Origin Request Issues :slight_smile:

26 Likes

Hi. I moved your post to a different category, so it’s more visible :slight_smile:

1 Like

Thanks. This article was so helpful. I read many other article and either they didn’t mention the" origin=*" or I am skimmed by it.

1 Like

Glad you found it helpful! :slight_smile:

This is very helpful. Thanks for sharing :slight_smile: -}

1 Like

Thank you for this! It was really helpful :smiley:

1 Like

You’re a lifesaver.

(…Clearly I just need to read the whole thing next time…)

2 Likes

Thanks, I was lost with this challenge, I thought it would be like the weather app, but the I get stuck. Your article was really helpfull.

1 Like

Please enjoy watching mine and give me more opinions :blush:

its really helpful. Thanks A lot.
By the way does apply to all error like this one?

hello
i hope you will read that but i do everything you wrote
same api and same parameters and this return string to me
so
$.ajax({type:“GET”,
datatype:“Json”,
data:{origin:"*"},
success:function({}):
i use inside function
alert (typeof(json)) and show string not object at all
why that
});

1 Like

Thanks so much, this helped me so much!

1 Like

it worked ,thanks :slight_smile:

2 Likes

Hello gcamacho079,

Thanks you so much for your article about the CORS Request Issues you have unblocked me for the Wikipedia Viewer,:smiley:

2 Likes

This was a great help, thank you.
I still had trouble after this, because my button was a submit type. I removed that, and everything worked.

1 Like

Thank You VERY much! I read a lot about CORS, everything look fine but - nothing worked. That was button type. I would never come to this by myself.

1 Like

Not working for me…

https://wikipedia.org/w/api.php?action=query&format=json&prop=extracts&list=&continue=&titles=&generator=search&callback=&formatversion=1&exsentences=3&exintro=1&explaintext=1&exsectionformat=plain&gsrsearch=javascript&origin=*

I have my &origin=* set, but still getting

Failed to load https://wikipedia.org/w/api.php?action=query&format=json&prop=extracts&list=&continue=&titles=&generator=search&callback=&formatversion=1&exsentences=3&exintro=1&explaintext=1&exsectionformat=plain&gsrsearch=json&origin=*: Redirect from 'https://wikipedia.org/w/api.php?action=query&format=json&prop=extracts&list=&continue=&titles=&generator=search&callback=&formatversion=1&exsentences=3&exintro=1&explaintext=1&exsectionformat=plain&gsrsearch=json&origin=*' to 'https://www.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&list=&continue=&titles=&generator=search&callback=&formatversion=1&exsentences=3&exintro=1&explaintext=1&exsectionformat=plain&gsrsearch=json&origin=*' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Here it is:
[FCC] Wikipedia Viewer

1 Like

This was the best thing I have seen all day. Thank you so much!