ENV, AXIOS, BASIC AUTH - env var not being processed on auto build

Having an issue with one .env variable when using automatic build/deploy.

The env variable for my basic auth password which is set in the UI is not being processed when making a post request with AXIOS using basic auth headers. The AXIOS request looks like this:

  this.$axios.post(api, { data }, {
        withCredentials: true,
        auth: {
          username: 'admin'
          password: process.env.AUTH_PASS
        headers: {
          'Content-Type': 'application/json'

When the POST request is sent from the deployed build it’s missing the final password which should be populated from Netlify env variables. eg the auth header is sent as authorization: Basic YWRtaW46 which decodes to ‘admin:’ so it’s missing the password and only has the username in the request header.

Going through everything to check whats working I have already tried

  • withCredentials
  • Cors
  • Netlify Redirects for proxy urls

When using netlify dev and deploying from the cli this works fine. So it’s not a CORS issue, it isn’t an issue with my headers… it’s just one variable for a password.

Is netlify detecting I am using a password with the .env variable and removing it on build?

1 Like

Does this help: [Support Guide] Using environment variables on Netlify correctly?

1 Like