PronounsPage/server/dotenv.ts
Valentyne Stigloher 4f7ccab2c6 (nuxt) use --env-file to read .env before nitro reads process.env, make dotenv.ts an import with side effects that only sets additional variables
care must be taken because everything initialized later will not be picked up by Nitro useRuntimeConfig() without passing an event
2025-03-14 22:18:09 +01:00

13 lines
360 B
TypeScript

import fs from 'node:fs/promises';
import { rootDir } from './paths.ts';
const publicKeyFile = `${rootDir}/keys/public.pem`;
try {
process.env.NUXT_PUBLIC_PUBLIC_KEY = await fs.readFile(publicKeyFile, 'utf-8');
} catch (error) {
console.error(error);
}
process.env.NUXT_PUBLIC_CLOUDFRONT = `https://${process.env.AWS_CLOUDFRONT_ID}.cloudfront.net`;