Search code examples
vue.jselectronelectron-builderquasar-frameworkelectron-packager

Set API URL for Quasar in the Electron mode build


I want to set my API URL for Electron mode. When I built my code to Electron production mode, All of my API URLs disappear first of the URL such as this: file:///core/v1/api/main/login

How can I set my API URL(an external IP address) for Electron mode in Production?


Solution

  • I found the solution. for this case, we could change the axios.js in the boot directory.

    For example, I need to change the baseURL to another when I build to Electron mode.

    if (process.env.MODE === 'electron') {
      var axiosInstance = axios.create({
        baseURL: process.env.API_URL
      })
      Vue.prototype.$axios = axiosInstance
    } else {
      Vue.prototype.$axios = axios
    }