diff --git a/packages/hoppscotch-backend/src/main.ts b/packages/hoppscotch-backend/src/main.ts index 920f7cce9..5515e804b 100644 --- a/packages/hoppscotch-backend/src/main.ts +++ b/packages/hoppscotch-backend/src/main.ts @@ -6,10 +6,21 @@ import { VersioningType } from '@nestjs/common'; import * as session from 'express-session'; import { emitGQLSchemaFile } from './gql-schema'; +function checkRequiredEnvVars(requiredEnvVariables: string[]) { + for (const envVar of requiredEnvVariables) { + if (!process.env[envVar]) { + console.error(`Environment variable "${envVar}" is missing or not set.`); + process.exit(1); // Exit the application with a non-zero status code to indicate an error + } + } +} + async function bootstrap() { console.log(`Running in production: ${process.env.PRODUCTION}`); console.log(`Port: ${process.env.PORT}`); + checkRequiredEnvVars(['ALLOWED_AUTH_PROVIDERS']); + const app = await NestFactory.create(AppModule); app.use(