使用enableCores 方法
const app = await NestFactory.create(AppModule); // 开启跨域 app.enableCors(); await app.listen(3000);
直接在创建模块时传入参数
const app = await NestFactory.create(AppModule, { cors: true }); await app.listen(3000);
www.haizhuan.tk