WeChat development tools return to normal
{ code: 2, msg: 'Invalid file' }
WeChat client returns
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 framework
koa-multer middleware, processing uploaded files
When the file is too large or has the wrong type, an error is thrown
Error handling middleware
async function errorHandler (ctx, next) {
try {
await next()
}
catch (err) {
let msg = parseError(err)
ctx.body = { code: 2, msg }
ctx.type = 'application/json'
}
}
I found the reason, it is related to pm2. It restarts as soon as an error is thrown, and catch is useless. WeChat development tools and clients, and network processing should be different