亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

node.js - WeChat applet background apache reverse proxy nodejs, when uploading invalid files, returns an error response?
高洛峰
高洛峰 2017-05-16 13:26:14
0
1
1073

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'
  }
}
高洛峰
高洛峰

擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級(jí)軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...

reply all(1)
洪濤

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template