import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { NestExpressApplication } from '@nestjs/platform-express'; import { join } from 'path'; async function bootstrap() { const app = await NestFactory.create(AppModule); // Serve static files from public directory app.useStaticAssets(join(__dirname, '..', 'public')); // Allow web app to call API in dev const webOrigin = process.env.WEB_APP_URL ?? 'http://localhost:5173'; app.enableCors({ origin: webOrigin, credentials: true, }); // Prefix all routes with /api app.setGlobalPrefix('api'); const port = process.env.PORT ? Number(process.env.PORT) : 3000; await app.listen(port); console.log(`API listening on ${await app.getUrl()}`); } void bootstrap();