bencodezen / vue-enterprise-boilerplate

An ever-evolving, very opinionated architecture and dev environment for new Vue SPA projects using Vue CLI.
7.78k stars 1.32k forks source link

API_BASE_URL for production build #163

Closed 6opuc closed 5 years ago

6opuc commented 5 years ago

How to configure API_BASE_URL for production build?

girls-whocode commented 5 years ago

If you're using Windows, put it in your environment variables.

Click on start Type in computer Right mouse click on "This PC" and click properties Click on advanced system settings Click on environment variables Click on new Variable name is "API_BASE_URL" (without the quotes" Variable value is the URL you want

If you're using Linux, Open your .basrc or .bash_profile (they both will work) Add API_BASE_URL='your URL'

You will have to reload the terminal window on both OS's

Hope this helps

openindustryorg commented 5 years ago

If using Windows via power shell you can:

$env:API_BASE_URL="https://THEURL"; yarn dev

girls-whocode commented 5 years ago

I guessing you can place that in your package.json file?

Then in Linux couldn't you do: API_BASE_URL='http://TheUrl'; yarn dev

redeemefy commented 5 years ago

You can create a config.js file in the root with the following.

export default {
  apiURL: process.env.API_URL || 'http://127.0.0.1:<portNumber>'
}

Then in main.js

import config from './config'

Vue.prototype.$http = axios
Vue.prototype.$http.defaults.baseURL  = config.apiURL
chrisvfritz commented 5 years ago

Looks like this is maybe resolved? Thanks @jessicakennedy1028, @openindustryorg, and @diazgilberto!