26 lines
756 B
TypeScript
26 lines
756 B
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
// 启用 CORS 支持多平台访问
|
|
app.enableCors({
|
|
origin: true,
|
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'],
|
|
credentials: true,
|
|
});
|
|
|
|
// 设置全局前缀
|
|
app.setGlobalPrefix('');
|
|
|
|
const port = process.env.PORT ?? 3000;
|
|
await app.listen(port);
|
|
|
|
console.log(`🚀 多平台小程序后台服务启动成功!`);
|
|
console.log(`📡 服务地址: http://localhost:${port}`);
|
|
console.log(`📋 模板管理 API: http://localhost:${port}/api/v1/templates`);
|
|
}
|
|
bootstrap();
|