\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",[2000,2001],{"name":1985,"color":1986},{"name":1988,"color":1989},15696,"Environment variables not synced from `.env` file on production build.","2023-01-19T18:20:11Z","https://github.com/nuxt/nuxt/issues/15696",0.60018116,{"description":2008,"labels":2009,"number":2012,"owner":1991,"repository":1991,"state":1992,"title":2013,"updated_at":2014,"url":2015,"score":2016},"### 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_",[2010,2011],{"name":1985,"color":1986},{"name":1988,"color":1989},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.60277736,{"description":2018,"labels":2019,"number":2021,"owner":1991,"repository":1991,"state":1992,"title":2022,"updated_at":2023,"url":2024,"score":2025},"### 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_",[2020],{"name":1988,"color":1989},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.6056285,{"description":2027,"labels":2028,"number":2031,"owner":1991,"repository":1991,"state":1992,"title":2032,"updated_at":2033,"url":2034,"score":2035},"### Environment\n\n------------------------------\r\n- Operating System: Darwin\r\n- Node Version: v18.14.0\r\n- Nuxt Version: 3.5.1\r\n- Nitro Version: 2.4.1\r\n- Package Manager: pnpm@8.6.0\r\n- Builder: vite\r\n- User Config: runtimeConfig, typescript, css, build, routeRules, vite, modules, gtm, devtools\r\n- Runtime Modules: @zadigetvoltaire/nuxt-gtm@0.0.13, nuxt-i18n-data@0.1.19, nuxt-vuetify-error-handler@1.1.0, nuxt-delay-hydration@1.2.0, (), @heiland/nuxt-hei-buttons@1.0.3, @pinia/nuxt@0.4.11, @nuxtjs/i18n@8.0.0-beta.12\r\n- Build Modules: -\r\n------------------------------\n\n### Reproduction\n\nhttps://stackblitz.com/edit/github-p8jezy\r\nrun npm build and the npm start (see package.json start script)\n\n### Describe the bug\n\nThe documentation https://nuxt.com/docs/guide/directory-structure/env says that we can define runtimeConfig env variables dynamically after build and before node start\r\n> On a Linux server, you could pass the environment variables as arguments using the terminal DATABASE_HOST=mydatabaseconnectionstring node .output/server/index.mjs\r\n\r\nBut that does not work. See the stackblitz reproduction. The RUNTIME_VAR defined before node start (see package.json start script) is not defined\n\n### Additional context\n\nI want to define differently environment variables depending on the stage (staging and prod). I deploying on AWS Beanstalk and using Bitbucket for CI/CD. \r\nIn Nuxt2 I can define env variables in AWS Beanstalk and the app will use this - but didnt work for nuxt3.\r\nFor nuxt3 I have to define the variables **before** npm run build is running. They seems to be static after that.\r\n\r\nI think a similiar bug / missing feature is described here https://github.com/nuxt/nuxt/issues/15366\n\n### Logs\n\n_No response_",[2029,2030],{"name":1985,"color":1986},{"name":1988,"color":1989},21559,"Define environment variable after npm build and before npm start","2023-07-03T21:02:41Z","https://github.com/nuxt/nuxt/issues/21559",0.60593736,{"description":2037,"labels":2038,"number":2041,"owner":1991,"repository":1991,"state":1992,"title":2042,"updated_at":2043,"url":2044,"score":2045},"### 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_",[2039,2040],{"name":1985,"color":1986},{"name":1988,"color":1989},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.61513233,{"description":2047,"labels":2048,"number":2055,"owner":1991,"repository":1991,"state":1992,"title":2056,"updated_at":2057,"url":2058,"score":2059},"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>",[2049,2052],{"name":2050,"color":2051},"question","cc317c",{"name":2053,"color":2054},"2.x","d4c5f9",2998,"Use environment variables inside nuxt.config.js","2023-01-18T16:09:50Z","https://github.com/nuxt/nuxt/issues/2998",0.6220688,{"description":2061,"labels":2062,"number":2065,"owner":1991,"repository":1991,"state":1992,"title":2066,"updated_at":2067,"url":2068,"score":2069},"### Environment\n\n------------------------------\r\n- Operating System: Windows_NT\r\n- Node Version: v20.11.1\r\n- Nuxt Version: 3.10.3\r\n- CLI Version: 3.10.1\r\n- Nitro Version: -\r\n- Package Manager: pnpm@8.15.4\r\n- Builder: -\r\n- User Config: devtools, runtimeConfig, nitro\r\n- Runtime Modules: -\r\n- Build Modules: -\r\n------------------------------\n\n### Reproduction\n\nThe reproduction is increadibly simple. Create a new Nuxt app with `pnpm dlx nuxi@latest init \u003Cproject-name>`.\r\n\r\n`nuxt.config.ts`\r\n```ts\r\nexport default defineNuxtConfig({\r\n devtools: {enabled: true},\r\n\r\n runtimeConfig: {\r\n public: {\r\n exampleValue: \"unknown\"\r\n }\r\n },\r\n \r\n nitro: {\r\n preset: \"cloudflare-pages\"\r\n }\r\n})\r\n```\r\n\r\n`app.vue`\r\n```vue\r\n\u003Ctemplate>\r\n \u003Cdiv>\r\n \u003Cstrong>Config:\u003C/strong>\r\n \u003Cpre>{{ config}}\u003C/pre>\r\n \u003C/div>\r\n\u003C/template>\r\n\r\n\u003Cscript setup lang=\"ts\">\r\nconst config = useRuntimeConfig();\r\n\u003C/script>\r\n```\r\n\r\nBuild the Nuxt app with `nuxt build` then deploy it to Cloudflare using `pnpm dlx wrangler pages deploy dist/`.\n\n### Describe the bug\n\nWhen the Nuxt app is deployed to Cloudflare Pages using the `cloudflare-pages` nitro preset, environment variables aren't passed down into Nuxt. Unless I've missed a step in configuring the Nuxt app or something else in Cloudflare, I would expect the `public.exampleValue` to be overridden with my environment value.\r\n\r\nThe hosted Nuxt app can be found here: https://pages-env-demo-55q.pages.dev/\r\n\r\n\r\nMy environment variable in Cloudflare Pages are configured like so:\r\n\r\n\n\n### Additional context\n\n_No response_\n\n### Logs\n\n_No response_",[2063,2064],{"name":1985,"color":1986},{"name":1988,"color":1989},26215,"Env variables not working on Cloudflare Pages","2024-03-14T16:40:18Z","https://github.com/nuxt/nuxt/issues/26215",0.6235203,{"description":2071,"labels":2072,"number":2077,"owner":1991,"repository":1991,"state":1992,"title":2078,"updated_at":2079,"url":2080,"score":2081},"### 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_",[2073,2076],{"name":2074,"color":2075},"documentation","5319e7",{"name":1985,"color":1986},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.62864673,{"labels":2083,"number":2086,"owner":1991,"repository":1991,"state":1992,"title":2087,"updated_at":2088,"url":2089,"score":2090},[2084,2085],{"name":1985,"color":1986},{"name":1988,"color":1989},14123,"useRuntimeConfig() is not work","2023-01-19T17:25:22Z","https://github.com/nuxt/nuxt/issues/14123",0.62967056,["Reactive",2092],{},["Set"],["ShallowReactive",2095],{"TRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"rUiQvZmKOuTB6AefPjf1DdLi7UVRSzdJ7YWK_rKMgSw":-1},"/nuxt/nuxt/22331"]