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 ?

Thank you

Answer

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.