-
Notifications
You must be signed in to change notification settings - Fork 164
Open
Description
Description
The module always writes new NUXT_SESSION_PASSWORD
variables to the default .env
file, even when a custom environment file is specified using the --dotenv
flag (e.g., pnpm dev --dotenv .env.local
).
Steps to Reproduce
- Create a custom environment file (e.g.,
.env.local
) - Run the development server with:
pnpm dev --dotenv .env.local
- Observe that
NUXT_SESSION_PASSWORD
is written to.env
instead of.env.local
Expected Behavior
When using --dotenv .env.local
, the module should write environment variables to the specified file (.env.local
) rather than the default .env
file.
Actual Behavior
The module always writes to .env
regardless of the --dotenv
flag, because the file path is hardcoded in the module.
Root Cause
In module.ts
, the environment file path is hardcoded:
// Current hardcoded implementation
const envPath = join(nuxt.options.rootDir, '.env');
Proposed Solution
Replace the hardcoded path with logic that respects the --dotenv
command-line argument:
const dotEnvIndex = process.argv.findIndex(arg => arg === '--dotenv')
const envPath = join(nuxt.options.rootDir, dotEnvIndex !== -1 ? process.argv[dotEnvIndex + 1] : '.env');
gabygarro
Metadata
Metadata
Assignees
Labels
No labels