微信开发工具返回正常
{ 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也没用,微信开发工具和客户端,网络处理应该不一样