[Vuejs]-How to setup Vue-axios cross-domain-origin for Laravel API?

-1👍

in vue.config.js, write the foreign url, and in axios, write the origin url from where you are attempting to access the foreign url. Here is an example:

module.exports = {
  devServer: {
    port: process.env.VUE_APP_DEV_PORT, // this should be: api.devport.findosman.xyz
    proxy: process.env.VUE_APP_API_ROOT_PATH,
  },
};

and when you start the request, use the origin url

axios.get(originUrl); // could be http://localhost or wherever from you're attempting to access that site

Leave a comment