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

234
Views
How to use .env value in nuxt.config.js with runtime config

I'm searching how to use a .env value in nuxt.config.js with runtime config.

Declare it, to use it in "normal" code is ok.

  publicRuntimeConfig: {
    URL_API: process.env.URL_API || 'http://localhost:8000/',
  },

But I want use .env value like this in my nuxt.config.js

  auth: {
    strategies: {
      local: {
        token: {
          property: 'token',
          required: true,
          maxAge: 1000 * 60 * 60
        },
        user: {
          property: 'user',
          autoFetch: false
        },
        clientID: true,
        endpoints: {
          login: { url: `${process.env.URL_API}/auth/login`, method: 'post' },
          logout: { url: `${process.env.URL_API}/auth/logout`, method: 'post' },
        },
        tokenType: ''
      }
    },
    redirect: {
      login: '/auth/login',
      logout: '/',
      callback: '/auth/login',
      home: '/'
    }
  },

Any idea?

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

0

As explained in my answer here: https://stackoverflow.com/a/67705541/8816585

If you have some modules located in nuxt.config.js, you can only pass env variables through process.env.MY_VARIABLE.
It is working if you're linking to an external file tho.

about 4 years ago · Juan Pablo Isaza Report

0

You can use dotenv package to use variables from .env file in nuxt.config.js.

nuxt.config.js file should look like this:

// your imports here

require('dotenv').config()

// nuxt config here
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!