fdesjardins/wikiquote

CORS Issue - No Access-Control-Allow-Origin set

zachurich opened this issue · 5 comments

When running webpack-dev-server, I face issues with CORS preventing me from making a complete request with wikiquote.

Is there anyway I can set this myself or should this be configured within the module?

Ah, yeah, this was developed for server-side JS, so you're going to get CORS issues unless we switch to using JSONP. I don't think there's a setting that will let us get around that.

I wouldn't be opposed to adding that functionality, though. I don't see any reason why this module couldn't also work in a browser environment.

That would be really helpful. I'm attempting to build a little app that lets the user get a random quote upon user input and I would like to keep it all client-side if possible. Great work on this btw! A promise-based interface for the wikiquote API is a god-send.

Hi, I am also getting this CORS issue, and I am also trying to build a random quote machine. Has this been patched?

Hey @RizwanSyed357, no, I haven't patched this yet. I use it primarily on the server, so I haven't hit the CORS issue myself. I'll take a look into adding it, but I'd appreciate a PR if you wanna take a stab at it.

This might be helpful. I've had success with CORS in browser on wikimedia apis just by adding &origin=* to the request. It could be pretty easy to modify each request to add this.

https://www.mediawiki.org/wiki/API:Cross-site_requests