|
4 | 4 |
|
5 | 5 | // Only process.env variables starting with `NEXT_PUBLIC_` will be shipped to the client: |
6 | 6 | import "./app/functions/server/notInClientComponent"; |
7 | | -import "./initializeEnvVars"; |
| 7 | + |
| 8 | +import { resolve } from "node:path"; |
| 9 | +import { fileURLToPath } from "node:url"; |
| 10 | +import env from "@next/env"; |
| 11 | + |
| 12 | +// Initialize variables from env file if appropriate |
| 13 | +// Doesn't run in tests by design, so ignore for coverage: |
| 14 | +/* c8 ignore start */ |
| 15 | +if ( |
| 16 | + typeof process.env.NEXT_RUNTIME !== "string" && |
| 17 | + (process.env.NODE_ENV !== "test" || process.env.PLAYWRIGHT === "true") |
| 18 | +) { |
| 19 | + // If we're in Next.js, our `.env` files are already set up to be loaded. |
| 20 | + // Outside of Next.js (e.g. in cron jobs), however, we need to explicitly load them. |
| 21 | + // (In unit tests, `next/jest` takes care of this, so no need to run this there.) |
| 22 | + env.loadEnvConfig(resolve(fileURLToPath(import.meta.url), "../../")); |
| 23 | +} |
| 24 | +/* c8 ignore end */ |
8 | 25 |
|
9 | 26 | // Don't need to have coverage on config object |
10 | 27 | /* c8 ignore start */ |
@@ -92,6 +109,16 @@ export const config = { |
92 | 109 | }), |
93 | 110 | }, |
94 | 111 | }, |
| 112 | + aws: { |
| 113 | + accessKeyId: getEnvString("AWS_ACCESS_KEY_ID", { fallbackValue: "" }), |
| 114 | + secretAccessKey: getEnvString("AWS_SECRET_ACCESS_KEY", { |
| 115 | + fallbackValue: "", |
| 116 | + }), |
| 117 | + region: getEnvString("AWS_REGION", { fallbackValue: "us-west-1" }), |
| 118 | + s3: { |
| 119 | + logoBucket: getEnvString("S3_BUCKET", { fallbackValue: "" }), |
| 120 | + }, |
| 121 | + }, |
95 | 122 | } as const; |
96 | 123 | /* c8 ignore end */ |
97 | 124 |
|
|
0 commit comments