feat: runtime env

Support runtime environment variables using server components.

This will mean docker images can change env vars for runtime as required.
This commit is contained in:
Mythie
2023-11-12 13:10:30 +11:00
parent aec0d2ae97
commit 1cd60e1abb
29 changed files with 254 additions and 70 deletions

View File

@@ -12,6 +12,7 @@ import path from 'node:path';
import { ONE_HOUR, ONE_SECOND } from '../../constants/time';
import { getServerComponentSession } from '../../next-auth/get-server-session';
import { alphaid } from '../id';
import { getRuntimeEnv } from '../runtime-env/get-runtime-env';
export const getPresignPostUrl = async (fileName: string, contentType: string) => {
const client = getS3Client();
@@ -103,7 +104,9 @@ export const deleteS3File = async (key: string) => {
};
const getS3Client = () => {
if (process.env.NEXT_PUBLIC_UPLOAD_TRANSPORT !== 's3') {
const { NEXT_PUBLIC_UPLOAD_TRANSPORT } = getRuntimeEnv();
if (NEXT_PUBLIC_UPLOAD_TRANSPORT !== 's3') {
throw new Error('Invalid upload transport');
}