@dotenvage/node 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dotenvage-napi.darwin-arm64.node +0 -0
- package/dotenvage-napi.darwin-x64.node +0 -0
- package/dotenvage-napi.linux-arm64-gnu.node +0 -0
- package/dotenvage-napi.linux-x64-gnu.node +0 -0
- package/dotenvage-napi.win32-arm64-msvc.node +0 -0
- package/dotenvage-napi.win32-x64-msvc.node +0 -0
- package/nextjs/config.mjs +14 -32
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/nextjs/config.mjs
CHANGED
|
@@ -1,59 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Next.js configuration wrapper for dotenvage integration.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Use `dotenvage-next` bin script to start Next.js:
|
|
8
|
-
* "dev": "dotenvage-next dev"
|
|
9
|
-
* "build": "dotenvage-next build"
|
|
10
|
-
* The wrapper script loads env vars BEFORE Next.js starts, ensuring
|
|
11
|
-
* they're available everywhere including Edge Runtime.
|
|
12
|
-
*
|
|
13
|
-
* 2. **Without wrapper script (server-side only, no Edge Runtime):**
|
|
14
|
-
* Use `loadEnv()` from `@dotenvage/node/nextjs` in your config file:
|
|
15
|
-
* import { loadEnv } from '@dotenvage/node/nextjs'
|
|
16
|
-
* loadEnv()
|
|
17
|
-
* Note: This only works for server-side code, not Edge Runtime/middleware.
|
|
4
|
+
* Wrapping your Next.js config with `withDotenvage()` ensures that
|
|
5
|
+
* encrypted .env files are decrypted and loaded into `process.env`
|
|
6
|
+
* when `next.config.mjs` is evaluated (at build time and dev startup).
|
|
18
7
|
*
|
|
19
8
|
* Usage in next.config.mjs:
|
|
20
9
|
* import { withDotenvage } from '@dotenvage/node/nextjs/config'
|
|
21
|
-
* import nextMDX from '@next/mdx'
|
|
22
|
-
*
|
|
23
|
-
* const nextConfig = {
|
|
24
|
-
* // your config
|
|
25
|
-
* }
|
|
26
10
|
*
|
|
11
|
+
* const nextConfig = { ... }
|
|
27
12
|
* export default withDotenvage(nextConfig)
|
|
28
13
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* When NOT using the wrapper script, use `loadEnv()` directly in your config.
|
|
14
|
+
* If the `dotenvage-next` wrapper script already loaded env vars,
|
|
15
|
+
* `loadEnv()` is a no-op (idempotent).
|
|
32
16
|
*/
|
|
17
|
+
import { loadEnv } from "./loader.mjs";
|
|
33
18
|
|
|
34
19
|
/**
|
|
35
20
|
* Wraps a Next.js configuration object.
|
|
36
|
-
*
|
|
37
|
-
* When using `dotenvage-next` wrapper script, env vars are already loaded.
|
|
21
|
+
* Loads encrypted .env files via dotenvage before returning the config.
|
|
38
22
|
*
|
|
39
23
|
* @param {import('next').NextConfig | ((phase: string) => import('next').NextConfig)} config - Next.js config object or function
|
|
40
|
-
* @returns {import('next').NextConfig | ((phase: string) => import('next').NextConfig)} The same config
|
|
24
|
+
* @returns {import('next').NextConfig | ((phase: string) => import('next').NextConfig)} The same config, after loading env vars
|
|
41
25
|
*/
|
|
42
26
|
export function withDotenvage(config) {
|
|
43
|
-
|
|
44
|
-
// When using `dotenvage-next` wrapper script, env vars are already loaded
|
|
27
|
+
loadEnv();
|
|
45
28
|
return config;
|
|
46
29
|
}
|
|
47
30
|
|
|
48
31
|
/**
|
|
49
|
-
* Wraps a Next.js configuration function
|
|
50
|
-
*
|
|
32
|
+
* Wraps a Next.js configuration function.
|
|
33
|
+
* Loads encrypted .env files via dotenvage before returning the function.
|
|
51
34
|
*
|
|
52
35
|
* @param {(phase: string, defaultConfig: import('next').NextConfig) => import('next').NextConfig} configFn - Next.js config function
|
|
53
|
-
* @returns {(phase: string, defaultConfig: import('next').NextConfig) => import('next').NextConfig} The same function
|
|
36
|
+
* @returns {(phase: string, defaultConfig: import('next').NextConfig) => import('next').NextConfig} The same function, after loading env vars
|
|
54
37
|
*/
|
|
55
38
|
export function withDotenvageConfig(configFn) {
|
|
56
|
-
|
|
57
|
-
// When using `dotenvage-next` wrapper script, env vars are already loaded
|
|
39
|
+
loadEnv();
|
|
58
40
|
return configFn;
|
|
59
41
|
}
|