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:
+10
-1
@@ -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 }));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user