You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reproducing this is simple, FYI, I'm using Nitro without Nuxt.
If you follow the documentation you would end up with something like this in nitro.config.ts:
I figured from reading the code, that Nitro suppose to get values from .env using unjs/c12 & dotenv while looping for values in the file that start with NITRO_ prefix, but it doesn't work (at least on my local)
I found a solution that works for me, which is importing dotenv at the start of nitro.config.ts, which solves this issue.
If this is the standard way to do so, then I assume an example of it in the documentation would be helpful (it took me a long time to figure it out myself)
If this is not the standard way, which is what I believe to be so, then importing dotenv in the beginning of the [src/options.ts](https://github.com/unjs/nitro/blob/b153cea1f2e0805088bdc512f490539cccec69c4/src/options.ts) could solve the issue.
Additional context
What solved it for me is adding import 'dotenv/config' at the top:
Environment
Node v16.15.0
npm 8.5.5
nitropack ^0.4.4
Reproduction
Reproducing this is simple, FYI, I'm using Nitro without Nuxt.
If you follow the documentation you would end up with something like this in
nitro.config.ts
:And
.env
file:Trying to read the values in a route with:
you get empty values (the defaults).
While the expected behavior is to find the values from the
.env
file:Describe the bug
I figured from reading the code, that Nitro suppose to get values from
.env
using unjs/c12 & dotenv while looping for values in the file that start withNITRO_
prefix, but it doesn't work (at least on my local)I found a solution that works for me, which is importing dotenv at the start of
nitro.config.ts
, which solves this issue.If this is the standard way to do so, then I assume an example of it in the documentation would be helpful (it took me a long time to figure it out myself)
If this is not the standard way, which is what I believe to be so, then importing
dotenv
in the beginning of the[src/options.ts](https://github.com/unjs/nitro/blob/b153cea1f2e0805088bdc512f490539cccec69c4/src/options.ts)
could solve the issue.Additional context
What solved it for me is adding
import 'dotenv/config'
at the top:Logs
No response
The text was updated successfully, but these errors were encountered: