This commit is contained in:
tianmo committed 2026-09-29 18:00:00 +08:00
1 parent c6e2cb4d5b
commit 4833f7fa6a
1 file changed
+6 -1
+6 -1
View File
@@ -1,4 +1,5 @@
import { NestFactory } from '@nestjs/core';
import express from 'express';
import { Logger } from 'nestjs-pino';
import { AppModule } from './app.module';
import { loadEnvFile, readConfig } from './config/config';
@@ -16,6 +17,11 @@ async function bootstrap(): Promise<void> {
app.useLogger(app.get(Logger));
app.getHttpAdapter().getInstance().set('trust proxy', 1);
// 微信虚拟支付的回调是 XML 请求体,而 Nest 的 rawBody 只挂在 json/urlencoded
// 两个解析器上,对 application/xml 不生效。这里显式补一个文本解析器,
// 否则控制器拿到的是空对象,发货推送会一直失败。
app.use('/v1/payments', express.text({ type: ['application/xml', 'text/xml'], limit: '1mb' }));
// 管理后台跨域;小程序不走 CORS
app.enableCors({
origin: [cfg.ADMIN_ORIGIN],
@@ -29,4 +35,3 @@ async function bootstrap(): Promise<void> {
}
void bootstrap();