config.ts only returns the first object in nuxt

Viewed 23

I have this config.ts file:


const config = {
  staging:{
    baseUrl: 'someUrls/stag',
    authEndpointUrl: '',
    pubnubEndpointUrl: ''
  },
  development: {
    baseUrl: 'someUrl/dev',
    authEndpointUrl: '',
    pubnubEndpointUrl: ''
  },
  production: {
    baseUrl: 'someUrl/prod',
    authEndpointUrl: '',
    pubnubEndpointUrl: ''
  }
}

const nodeEnv = process.env.NODE_ENV ;

module.exports = config[nodeEnv]

and this is my nuxt.config.js:

import config from './config.ts';

.
.
.

  env:{
    config
  },
.
.
.

in my app if I use process.env.config.baseUrl it only returns the first object's baseUrl: 'someUrls/stag'. If I change the position of staginganddevelopmentin myconfig.tsit returnsbaseUrl: 'someUrl/dev'(again the first object). How can I grab the baseUrl from different objects that I have likeproduction`?

I tried process.env.config.production.baseUrl but it returns null! How can I access different objects in my config.ts file?

0 Answers
Related