fix(typeerror): 尝试修复vercel调用 500错误

This commit is contained in:
ImFurina 2025-10-07 15:08:05 +08:00
parent f9f6db3fee
commit 2cbd17a6d7

View File

@ -208,7 +208,9 @@ async function consturctServer(moduleDefs) {
// Register the route.
app.use(moduleDef.route, async (req, res) => {
;[req.query, req.body].forEach((item) => {
if (typeof item.cookie === 'string') {
// item may be undefined (some environments / middlewares).
// Guard access to avoid "Cannot read properties of undefined (reading 'cookie')".
if (item && typeof item.cookie === 'string') {
item.cookie = cookieToJson(decode(item.cookie))
}
})