微信開發工具回傳正常
{ code: 2, msg: '無效的檔案' }
微信客戶端回傳
Bad Gateway! The proxy server received an invalid response from an
upstream server.
apache
httpd-ssl.conf
<VirtualHost _default_:443>
ProxyPass /mina http://127.0.0.1:3000
ProxyPassReverse /mina http://127.0.0.1:3000
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</VirtualHost>
node
#koa 框架
koa-multer 中間件,處理上傳檔案
當檔案過大或類型錯誤時,拋出錯誤
#處理錯誤中間件
async function errorHandler (ctx, next) {
try {
await next()
}
catch (err) {
let msg = parseError(err)
ctx.body = { code: 2, msg }
ctx.type = 'application/json'
}
}
找到原因了,是pm2的關係,一拋錯誤就重啟,catch也沒用,微信開發工具和客戶端,網絡處理應該不一樣