[Vuejs]-Returning json data from url with Vue.js

0👍

You need to setup CORS policy for external API. It’s not related to vue.js.

Alternatively, if the external API is a 3rd-party API and you cannot change the CORS policy, then you can consume the external API in your server-side code and create your own API in your server-side code that will return whatever value you get from the external API.

0👍

From Vue Cli docs:

WARNING

When devServer.proxy is set to a string, only XHR requests will be proxied. If you want to test an API URL, don’t open it in the browser, use an API tool like Postman instead.

So, setting the devServer.proxy property, does not solve the issue, as api requests won’t be proxied. For a permanent solution, as Circuit Breaker suggested, you have to allow the CORS request on the api server.

Leave a comment