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

320
Views
How to use an environment variable in a Nuxt.js project for a file that is not injected as plugin?

I have a file in my Nuxt.js project that simply resides in the src directory. Therefore it is not in the convention of a Nuxt project. Therefore I understand that environment variables defined in the nuxt.config.js will not appear in the file placed in src.

However I'd still like to use environment variables in that mentioned file. This is how I try to access the environment variable:

const GAMESERVER_URL = process.env.GAMESERVER_URL || 'http://localhost:1001'

Unfortunately it always falls back to the default value http://localhost:1001. I have another file used as Nuxt.js plugin that is referencing the very same environment variable with the exact same statement (above). The plugin file works fine and is using the environment variable correctly.

What are my options to also introduce the environment variables to my standalone file in the src directory?

about 4 years ago · Juan Pablo Isaza
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!