first commit
This commit is contained in:
22
apps/api/src/main.ts
Normal file
22
apps/api/src/main.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
// 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);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`API listening on http://localhost:${port}`);
|
||||
}
|
||||
bootstrap();
|
||||
Reference in New Issue
Block a user