Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
process.env doesn't contain ENV VARS when `npm run build` (Ubuntu)

I'm deploying VueJS project. There is a file that contain API URLs where I use process.env. If API_URL is defined in production only so I can use localhost on my development server and API_URL in the production.

const apiRoot = process.env.API_URL || 'http://127.0.0.1:8000'

export default {
    root: apiRoot,
    auth: {
        jwt: {
            create: urljoin(apiRoot, "auth/jwt/login/"),
            refresh: urljoin(apiRoot, "auth/jwt/refresh/"),
        },
        loginPage: "/login",
        me: urljoin(apiRoot,"users/me/")
    }
}

On the server, I've added EXPORT API_URL='my.api.url' and then I ran npm run build. Then I realized it is still using 127.0.0.1:8000 so I also added the ENV VAR to /etc/environment file.

Again, no success. I've rebooted the server.

In cmd line I can do this:

echo $API_URL 
'my.api.url'

How to make it work? Or how to debug this issue?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The solution is simple. Each ENV VAR must start with VUE_APP_.

So instead of setting API_URL I need to set VUE_APP_API_URL

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!