diff --git a/plugins/sentry-backend/src/service/router.ts b/plugins/sentry-backend/src/service/router.ts index c6a0cbd593..3c750bed16 100644 --- a/plugins/sentry-backend/src/service/router.ts +++ b/plugins/sentry-backend/src/service/router.ts @@ -22,7 +22,12 @@ export async function createRouter( rootLogger: Logger, ): Promise { const router = Router(); - const sentryForwarder = new SentryApiForwarder(''); + const SENTRY_TOKEN = process.env.SENTRY_TOKEN; + if (!SENTRY_TOKEN) { + console.error('Sentry token must be provided in env to start the API.'); + process.exit(1); + } + const sentryForwarder = new SentryApiForwarder(SENTRY_TOKEN); const logger = rootLogger.child({ plugin: 'sentry' }); router.get('*', (req, res) => sentryForwarder.fowardRequest(req, res)); diff --git a/plugins/sentry-backend/src/service/standaloneServer.ts b/plugins/sentry-backend/src/service/standaloneServer.ts index 3fc55fb7d0..37b87c5c40 100644 --- a/plugins/sentry-backend/src/service/standaloneServer.ts +++ b/plugins/sentry-backend/src/service/standaloneServer.ts @@ -18,8 +18,6 @@ import { Server } from 'http'; import { Logger } from 'winston'; import { createStandaloneApplication } from './standaloneApplication'; -const PORT = 5009; - export async function startStandaloneServer( parentLogger: Logger, ): Promise { @@ -29,6 +27,7 @@ export async function startStandaloneServer( const app = await createStandaloneApplication(logger); logger.debug('Starting application server...'); + const PORT = parseInt(process.env.PORT || '5001', 10); return await new Promise((resolve, reject) => { const server = app.listen(PORT, (err?: Error) => { if (err) { diff --git a/plugins/sentry/src/data/api-factory.ts b/plugins/sentry/src/data/api-factory.ts index 32ff4bde5c..0b82637cb4 100644 --- a/plugins/sentry/src/data/api-factory.ts +++ b/plugins/sentry/src/data/api-factory.ts @@ -18,7 +18,7 @@ import { MockSentryApi } from './mock-api'; import { ProductionSentryApi } from './production-api'; export function sentryApiFactory(organization: string): SentryApi { - if (process.env.NODE_ENV === 'production') { + if (process.env.NODE_ENV !== 'production') { return new ProductionSentryApi(organization); } return new MockSentryApi();