fix: 配置微信小程序域名的跨域 CORS

- 添加 servicewechat.com、miniapp-api-test.dxz99wyr.cn、api-miniapp.dxz99wyr.cn 到 CORS origin
- 允许 GET/POST/PUT/DELETE/OPTIONS 方法
- 允许 Content-Type/Authorization/Accept/Origin/X-Requested-With 请求头
This commit is contained in:
Developer
2026-05-18 21:41:42 +08:00
parent 1117bd0bd7
commit 608ee017d4
+10 -1
View File
@@ -41,7 +41,16 @@ app.use(helmet({
}, },
}, },
})); }));
app.use(cors()); app.use(cors({
origin: [
'https://servicewechat.com',
'https://miniapp-api-test.dxz99wyr.cn',
'https://api-miniapp.dxz99wyr.cn'
],
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'Accept', 'Origin', 'X-Requested-With'],
credentials: false
}));
app.use(express.json({ limit: '10mb' })); app.use(express.json({ limit: '10mb' }));
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));