Search code examples
google-chromexmlhttprequestcorsplunker

No 'Access-Control-Allow-Origin' header in plunker


I see there are lots of threads about No 'Access-Control-Allow-Origin' header. My question is about how to solve this in plunker.

I have a piece of code in plunker, which tries to load an external html file. It gives an error No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://run.plnkr.co' is therefore not allowed access.

I tried to launch Chrome by open /Applications/Google\ Chrome.app --args --disable-web-security, but it did not help.

Does anyone have any workaround to make loading an external html file work in plunker?


Solution

  • You can use an open CORS proxy like https://cors-anywhere.herokuapp.com/.

    The way it works is, instead of making your request directly to https://site.to.request you make your request to https://cors-anywhere.herokuapp.com/https://site.to.request.

    The https://cors-anywhere.herokuapp.com/ proxy then adds the necessary CORS headers.

    Or you can run your own instance from the source at https://github.com/Rob--W/cors-anywhere/