NuxtN
Nuxt3y ago
Talaxasy

How to use env variables inside /utils folder?

I want to access env variables from inside /utils folder for ex.: I have constants.ts file and there:
export const isDev = process.env.NODE_ENV === 'development';
export const isConsoleDebugSee = process.env.CONSOLE_DEBUG;
export const isConsoleDebug = process.env.CONSOLE_DEBUG
  ? process.env.CONSOLE_DEBUG === 'true'
  : undefined;
export const isPreviewDebug = process.env.DISPLAY_PREVIEW_CONETENT
  ? process.env.DISPLAY_PREVIEW_CONETENT === 'true'
  : undefined;
export const isConsole =
  typeof isConsoleDebug !== 'undefined' ? isConsoleDebug : isDev;
export const isPreview =
  typeof isPreviewDebug !== 'undefined' ? isPreviewDebug : isDev;

In a frontend console I see that CONSOLE_DEBUG always is undefined, but I have access to process.env.NODE_ENV
Was this page helpful?