0

I need to do a GET request from a CORS enabled corona virus API with axios and Vue, and I have no control over their server. My Vue app was created with vue-cli.

Actually I do two requests from different API's, one works without CORS the other with the exact same code, but on a second component complains just because the server enforces CORS

Access to XMLHttpRequest at 'http://corona-api.com/countries' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

What can I do?

3
  • Proxy the calls through your server. Ask the API provider to permit CORS. Find another API. Commented Apr 10, 2020 at 19:19
  • @ceejayoz I think I would like to try the proxy solution. Can you provide a url? Commented Apr 10, 2020 at 19:23
  • 1
    Link to what? He meant using your own webserver as proxy. Commented Apr 10, 2020 at 19:29

1 Answer 1

1

the issue is that http is being redireced to https, you get a redirect header, which is absent of wildcard CORS policy.

as you can see, https://codesandbox.io/s/javascript-es6-axios-app-y80n5

this works fine for axios request to 'https://corona-api.com/countries'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.