\r\n \u003C/div>\r\n\u003C/template>\r\n\u003Cscript setup>\r\nconst config = useRuntimeConfig();\r\nconsole.log(config);\r\n\u003C/script>\r\n\r\n```\r\n\r\nNow, when I build the project using `yarn build` and then run the production build using `node .output/server/index.mjs`, I get the following output:\r\n\r\n```shell\r\n~/projects/nuxt-starter-ilkcf5 6s\r\n❯ node .output/server/index.mjs\r\nListening http://[::]:3000\r\n{\r\n app: { baseURL: '/', buildAssetsDir: '/_nuxt/', cdnURL: '' },\r\n nitro: { routeRules: { '/__nuxt_error': [Object] }, envPrefix: 'NUXT_' },\r\n public: { apiBaseUrl: '' }\r\n}\r\n```\r\n\r\nNotice that the `config` variable that is getting logged in `app.vue` has a public key of `apiBaseUrl` as `\"\"` as opposed to `http://localhost:8000` as defined in the `.env` file.\r\n\r\nNOTE that this is not an issue when running `yarn dev`.\r\n\r\nJust want to know if this is really a bug or am I missing a step here.\r\n\r\n### Additional context\r\n\r\n_No response_\r\n\r\n### Logs\r\n\r\n```shell\r\n~/projects/nuxt-starter-ilkcf5 6s\r\n❯ node .output/server/index.mjs\r\nListening http://[::]:3000\r\n{\r\n app: { baseURL: '/', buildAssetsDir: '/_nuxt/', cdnURL: '' },\r\n nitro: { routeRules: { '/__nuxt_error': [Object] }, envPrefix: 'NUXT_' },\r\n public: { apiBaseUrl: '' }\r\n}\r\n```\r\n",[3171,3172],{"name":3146,"color":3147},{"name":3149,"color":3150},15696,"Environment variables not synced from `.env` file on production build.","2023-01-19T18:20:11Z","https://github.com/nuxt/nuxt/issues/15696",0.6144977,{"description":3179,"labels":3180,"number":3183,"owner":3152,"repository":3152,"state":3153,"title":3184,"updated_at":3185,"url":3186,"score":3187},"### Environment\r\n\r\nRootDir: /home/projects/github-qrbpqh 05:30:19\r\nNuxt project info: 05:30:19\r\n\r\n------------------------------\r\n- Operating System: `Linux`\r\n- Node Version: `v16.14.2`\r\n- Nuxt Version: `3.1.1`\r\n- Nitro Version: `2.1.1`\r\n- Package Manager: `npm@7.17.0`\r\n- Builder: `vite`\r\n- User Config: `runtimeConfig`\r\n- Runtime Modules: `-`\r\n- Build Modules: `-`\r\n------------------------------\r\n\r\n### Reproduction\r\n\r\nhttps://stackblitz.com/edit/github-qrbpqh?file=app.vue,nuxt.config.ts\r\n\r\n1. Add a `.env` to the base dir:\r\n\r\n```bash\r\nNUXT_PUBLIC_SITE_URL=\"http://mysite.com\"\r\n```\r\n\r\nRun `npm install && npm run dev`.\r\n\r\nYou see that the `nuxt-simple-sitemap` module, which depends on the `runtimeConfig.public.siteUrl` being defined, throwing an error.\r\n\r\n### Describe the bug\r\n\r\nThe docs say you can write env variables like this:\r\n\r\nhttps://nuxt.com/docs/guide/going-further/runtime-config#environment-variables\r\n\r\n```ts\r\nexport default defineNuxtConfig({\r\n runtimeConfig: {\r\n apiSecret: '', // can be overridden by NUXT_API_SECRET environment variable\r\n public: {\r\n apiBase: '', // can be overridden by NUXT_PUBLIC_API_BASE environment variable\r\n }\r\n },\r\n})\r\n```\r\n\r\nand `.env`\r\n\r\n```\r\nNUXT_API_SECRET=api_secret_token\r\nNUXT_PUBLIC_API_BASE=https://nuxtjs.org\r\n```\r\n\r\nIn the newest nuxt version, this does not work anymore. The string stays empty after build, so the `.env` variables are not injected.\r\n\r\nWhat works is setting it manually like\r\n\r\n```ts\r\nexport default defineNuxtConfig({\r\n runtimeConfig: {\r\n apiSecret: process.env.NUXT_API_SECRET,\r\n public: {\r\n apiBase: process.env.NUXT_PUBLIC_API_BASE,\r\n }\r\n },\r\n})\r\n```\r\n\r\nIf this is by intention, I would add a PR to the docs to make it clear that modules do not have access to the config if you are using the empty-string syntax. Or I think it would actually be even clearer to get rid of that syntax and suggest always use the `process.env.NUXT_...` directly. \r\n\r\n### Additional context\r\n\r\n_No response_\r\n\r\n### Logs\r\n\r\n_No response_",[3181,3182],{"name":3146,"color":3147},{"name":3149,"color":3150},18692,"[Nuxt 3.1.1] Defining `runtimeConfig.public.myValue = ''` is not injected with `.env` at runtime of a module","2023-02-02T15:16:10Z","https://github.com/nuxt/nuxt/issues/18692",0.61457884,{"description":3189,"labels":3190,"number":3193,"owner":3152,"repository":3152,"state":3153,"title":3194,"updated_at":3195,"url":3196,"score":3197},"### Environment\n\nRootDir: /home/projects/github-qrbpqh 05:30:19\r\nNuxt project info: 05:30:19\r\n\r\n------------------------------\r\n- Operating System: `Linux`\r\n- Node Version: `v16.14.2`\r\n- Nuxt Version: `3.1.1`\r\n- Nitro Version: `2.1.1`\r\n- Package Manager: `npm@7.17.0`\r\n- Builder: `vite`\r\n- User Config: `runtimeConfig`\r\n- Runtime Modules: `-`\r\n- Build Modules: `-`\r\n------------------------------\n\n### Reproduction\n\nhttps://stackblitz.com/edit/github-qrbpqh?file=app.vue,nuxt.config.ts\r\n\r\nRun `npm i && npm run build && npm run preview`,\n\n### Describe the bug\n\nThe docs say you can write env variables like this:\r\n\r\nhttps://nuxt.com/docs/guide/going-further/runtime-config#environment-variables\r\n\r\n```ts\r\nexport default defineNuxtConfig({\r\n runtimeConfig: {\r\n apiSecret: '', // can be overridden by NUXT_API_SECRET environment variable\r\n public: {\r\n apiBase: '', // can be overridden by NUXT_PUBLIC_API_BASE environment variable\r\n }\r\n },\r\n})\r\n```\r\n\r\nand `.env`\r\n\r\n```\r\nNUXT_API_SECRET=api_secret_token\r\nNUXT_PUBLIC_API_BASE=https://nuxtjs.org\r\n```\r\n\r\nIn the newest nuxt version, this does not work anymore. The string stays empty after build, so the `.env` variables are not injected\n\n### Additional context\n\n_No response_\n\n### Logs\n\n_No response_",[3191,3192],{"name":3146,"color":3147},{"name":3149,"color":3150},18691,"[Nuxt 3.1.1] Defining `runtimeConfig.public.myValue = ` is not work with `NUXT_PUBLIC_MY_VALUE` anymore","2023-02-02T12:53:13Z","https://github.com/nuxt/nuxt/issues/18691",0.6158783,{"description":3199,"labels":3200,"number":3205,"owner":3152,"repository":3152,"state":3153,"title":3206,"updated_at":3207,"url":3208,"score":3209},"### Environment\n\ndevelopment --------------\n- Operating System: Windows_NT\n- Node Version: v23.9.0\n- Nuxt Version: 4.1.1\n- CLI Version: 3.28.0\n- Nitro Version: 2.12.5\n- Package Manager: pnpm@10.15.1\n- Builder: -\n- User Config: compatibilityDate, devtools, runtimeConfig\n- Runtime Modules: -\n- Build Modules: -\n------------------------------\n\nproduction -----------------\n- Operating System: Linux\n- Node Version: v24.6.0\n- Nuxt Version: ^4.1.1\n- CLI Version: 3.28.0\n- Nitro Version: -\n- Package Manager: pnpm@10.15.1\n- Builder: -\n- User Config: compatibilityDate, devtools, runtimeConfig\n- Runtime Modules: -\n- Build Modules: -\n------------------------------\n\n### Reproduction\n\nhttps://github.com/sooooooooooooooooootheby/actions\n\n### Describe the bug\n\nIn the development environment, the front end cannot obtain the `HOST` variable. However, when deployed on the server, all the environment variables will be exposed. \n\nThe deployment on the server is done using pm2.\n\n```bash\npm2 start ecosystem.config.cjs --env .env\n```\n\n```ts\nruntimeConfig: {\n\tdatabaseHost: process.env.DATEBASE_HOST,\n\tpublic: {\n\t\tdatabaseUser: process.env.DATEBASE_USER,\n\t},\n},\n```\n\n\u003Cimg width=\"1319\" height=\"818\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/56feba7f-295a-4435-aad3-870a1990b6de\" />\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\n\n```",[3201,3202],{"name":3149,"color":3150},{"name":3203,"color":3204},"possible regression","B90A42",33204,"In the production environment, `useRuntimeConfig()` will expose all the environment variables.","2025-09-11T07:34:28Z","https://github.com/nuxt/nuxt/issues/33204",0.6181153,{"description":3211,"labels":3212,"number":3214,"owner":3152,"repository":3152,"state":3153,"title":3215,"updated_at":3216,"url":3217,"score":3218},"### Environment\n\n- Operating System: Darwin\r\n- Node Version: v22.0.0\r\n- Nuxt Version: 3.12.2\r\n- CLI Version: 3.12.0\r\n- Nitro Version: 2.9.7\r\n- Package Manager: pnpm@9.6.0\r\n- Builder: -\r\n- User Config: future, modules, hub, ui, eslint, devtools\r\n- Runtime Modules: nuxt-auth-utils@0.1.0, @nuxthub/core@0.7.0, @nuxt/eslint@0.3.13, @nuxt/ui@2.17.0\r\n- Build Modules: -\n\n### Reproduction\n\nhttps://stackblitz.com/edit/github-fhawmu?file=.env.development\r\n\r\n\u003Cimg width=\"1910\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b8348784-34cb-4104-9d32-c4d29c1381e4\">\r\n\r\n\n\n### Describe the bug\n\nWhen running pnpm dev , I found that useRuntimeConfig() can get environment variables from `.env` environment configuration, but cannot get environment variables from `.env.local` and `.env.development`.. \r\nI need help, Thanks!\n\n### Additional context\n\n_No response_\n\n### Logs\n\n_No response_",[3213],{"name":3149,"color":3150},28309,"When running pnpm dev, Unable to automatically get environment variables from `.env.local` and `.env.development`","2024-07-31T07:43:43Z","https://github.com/nuxt/nuxt/issues/28309",0.6193018,{"description":3220,"labels":3221,"number":3226,"owner":3152,"repository":3152,"state":3153,"title":3227,"updated_at":3228,"url":3229,"score":3230},"### Environment\r\n\r\nNuxt CLI v3.0.0-rc.8 \r\n\r\n------------------------------\r\n- Operating System: `Linux`\r\n- Node Version: `v16.14.2`\r\n- Nuxt Version: `3.0.0-rc.8`\r\n- Package Manager: `npm@7.17.0`\r\n- Builder: `vite`\r\n- User Config: `runtimeConfig`\r\n- Runtime Modules: `-`\r\n- Build Modules: `-`\r\n------------------------------\r\n\r\n### Reproduction\r\n\r\nSample: https://stackblitz.com/edit/github-dnbk4c-y5bqyg?file=package.json,nuxt.config.tsnp\r\nThe config:\r\n```js\r\nexport default defineNuxtConfig({\r\n runtimeConfig: {\r\n public: {\r\n API_HOST: process.env.API_HOST || '',\r\n },\r\n },\r\n});\r\n```\r\n\r\nSteps:\r\n1. yarn build\r\n2. Create a env var via: export API_HOST=\"something\"\r\n3. yarn start\r\n\r\nLook at the console log which prints out the runtime config\r\n\r\n### Describe the bug\r\n\r\nEnvironment variable set after the nuxt build are not being registered in the runtime config\r\n\r\n### Additional context\r\n\r\n_No response_\r\n\r\n### Logs\r\n\r\n_No response_",[3222,3225],{"name":3223,"color":3224},"documentation","5319e7",{"name":3146,"color":3147},14721,"Enivornment variables in runtimeConfig not being set at runtime (Nuxt rc.8)","2023-01-19T17:39:20Z","https://github.com/nuxt/nuxt/issues/14721",0.62463003,{"labels":3232,"number":3235,"owner":3152,"repository":3152,"state":3153,"title":3236,"updated_at":3237,"url":3238,"score":3239},[3233,3234],{"name":3146,"color":3147},{"name":3149,"color":3150},14123,"useRuntimeConfig() is not work","2023-01-19T17:25:22Z","https://github.com/nuxt/nuxt/issues/14123",0.6294201,{"description":3241,"labels":3242,"number":3249,"owner":3152,"repository":3152,"state":3153,"title":3250,"updated_at":3251,"url":3252,"score":3253},"Hey!\r\n\r\n## Description\r\n\r\nI'm currently trying to set several config parameters depending on whether nuxt.js is launched in dev or production mode. To accomplish this, I haven't changed any environment variables before starting nuxt.\r\nUnfortunately, the following won't work (using the axios module) by default:\r\n\r\n```\r\n /*\r\n * Axios\r\n */\r\n axios: {\r\n baseURL: process.env.NODE_ENV !== 'production' ? 'http://api.xyz.test' : 'https://api.xyz.com'\r\n },\r\n```\r\n\r\nIf I use `console.log(process.env.NODE_ENV)` in the `nuxt.config.js` file, it's undefined (if not set before)\r\n\r\n## Current possible solution\r\n\r\nI only came up with one solution for it:\r\n\r\n### Set env variables before starting\r\n\r\nWe could update the package.json scripts to include NODE_ENV or set it manually through the console.\r\nThe former blocks \"overriding\" ENV through the command line, the latter is quite tedious.\r\n```\r\n\"scripts\": {\r\n \"dev\": \"NODE_ENV=development nuxt\",\r\n \"build\": \"NODE_ENV=production nuxt build\",\r\n \"start\": \"NODE_ENV=production nuxt start\",\r\n \"generate\": \"NODE_ENV=production nuxt generate\", \r\n },\r\n```\r\n\r\n### Use dotenv module\r\n\r\nAlso a way to deal with it, and highly customizable. Still, there should be an easier way to define the \"default\" configuration which would be enough in many use-cases.\r\n\r\n## Other solutions?\r\n\r\nAre there better ways to accomplish similar behavior easier?\r\n\r\nBy default, NODE_ENV is set depending on the nuxt mode (`nuxt dev` = development, production otherwise), but I guess this happens after interpreting the config.\r\n\r\nCould we use `extend()` for it? :thinking: \r\n\r\n## Related\r\nhttps://github.com/nuxt/nuxt.js/blob/dev/lib/builder/webpack/server.config.js#L50\r\nhttps://github.com/nuxt/nuxt.js/issues/1386\n\n\u003C!--cmty-->\u003C!--cmty_prevent_hook-->\n\u003Cdiv align=\"right\">\u003Csub>\u003Cem>This bug report is available on \u003Ca href=\"https://nuxtjs.cmty.io\">Nuxt.js\u003C/a> community (\u003Ca href=\"https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2598\">#c2598\u003C/a>)\u003C/em>\u003C/sub>\u003C/div>",[3243,3246],{"name":3244,"color":3245},"question","cc317c",{"name":3247,"color":3248},"2.x","d4c5f9",2998,"Use environment variables inside nuxt.config.js","2023-01-18T16:09:50Z","https://github.com/nuxt/nuxt/issues/2998",0.62950116,["Reactive",3255],{},["Set"],["ShallowReactive",3258],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$frUiQvZmKOuTB6AefPjf1DdLi7UVRSzdJ7YWK_rKMgSw":-1},"/nuxt/nuxt/22331"]