question

VeerlevanLeemput-7975 avatar image
0 Votes"
VeerlevanLeemput-7975 asked azure-cxp-api edited

Azure App Service does not take environment variables

I have deployed two Azure App Services. A front end and a back end. Both running on Node 14 LTS. Individually the services work fine. But they can't talk to each other.

I've specified the necessary environment variables in the settings:

104168-screenshot1.png



But if I go to my front end it picks up another VUE_APP_API_BASE_URL AND VUE_APP_API_PORT, and not the one I specified in the settings. So I get a 404 when making a request to the backend.

The front end makes use of this code:

 import axios from 'axios'
 const PORT = process.env.VUE_APP_API_PORT
 const BE_URL = process.env.VUE_APP_API_BASE_URL
    
 const instance = axios.create({
   withCredentials: true,
   headers: {
     'Content-Type': 'application/json;charset=UTF-8'
   },
   baseURL: BE_URL + PORT + '/api/'
 })
    
 export default instance

What could I be missing? When I look at the request that is being made, it's taking the URL of the front end as VUE_APP_API_BASE_URL, and not the one specified in the settings.

Perhaps anything I can add in the startup command that will help setting these two variables correctly?

Any help is greatly appreciated, I'm kind of very stuck!


azure-webappsazure-webapps-development
screenshot1.png (122.5 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

On the surface @VeerlevanLeemput-7975, that looks correct. Are any of your other process.env e.g. process.env.PORT retrieved correctly? If you're node app is running in a Linux app service plan, do you see the correct values after the --env?

0 Votes 0 ·

Hi @VeerlevanLeemput-7975, I wanted to follow up on my above comment. If you still need further assistance, please feel free to comment down below.

0 Votes 0 ·

0 Answers