2

I am trying to pass environment vairable setup inside asp.net core (kesterl) to vuejs My launchsettings is like

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "https://localhost:44323/",
      "sslPort": 44323
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "BEAPI_URL": "http://localhost:4000/api/v1",
        "VUE_BEAPI_URL": "http://localhost:4000/api/v1"
      }
    },    
  }
}

and my vuejs config is as following

export default {
    // apiUrl: 'http://localhost:4000/api/v1'    
    apiUrl: process.env.VUE_BEAPI_URL
    
}

Anyone help like my scenario Other then this my vuejs app is working fine under kesterl

Kamran Shahid
  • 3,954
  • 5
  • 48
  • 93
  • What version of vue.js you are using? May be you need to add the Prefix VUE_APP_ to ENVs to make them available in your vue.js application. https://stackoverflow.com/q/50828904/83039 – Jehof Mar 17 '21 at 11:12
  • I have tried adding VUE_APP_ suffix but no effect. vuejs version is 2.6.12 – Kamran Shahid Mar 17 '21 at 11:28

1 Answers1

0

Following settings have worked kesterl launchsetting (for environment variable name reference)

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "https://localhost:44323/",
      "sslPort": 44323
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "VUE_APP_BEAPI_URL": "http://localhost:4000/api/v1"
      }
    }
  }
}

vuejs config

export default {
    // apiUrl: 'http://localhost:4000/api/v1',
    apiUrl: process.env.VUE_APP_BEAPI_URL,
    access_token:''
}
Kamran Shahid
  • 3,954
  • 5
  • 48
  • 93