import { NestFactory } from '@nestjs/core'; import type { NestExpressApplication } from '@nestjs/platform-express'; import { join } from 'path'; import { AppModule } from './app.module'; import { ConfigService } from '@nestjs/config'; async function bootstrap() { const app = await NestFactory.create(AppModule); const config = app.get(ConfigService); app.enableCors({ origin: config.get('corsOrigin'), credentials: true, }); // Serve widget.js and other static files from /public // In dev mode __dirname = src/, in prod __dirname = dist/ — resolve from process.cwd() app.useStaticAssets(join(process.cwd(), 'public'), { setHeaders: (res, path) => { if (path.endsWith('.js')) { res.setHeader('Cache-Control', 'public, max-age=3600'); res.setHeader('Access-Control-Allow-Origin', '*'); } }, }); const port = config.get('port'); await app.listen(port); console.log(`Helix Engage Server running on port ${port}`); } bootstrap();