Restify在出现错误时忽略nginx头

Restify在出现错误时忽略nginx头,nginx,restify,Nginx,Restify,我正在用restify+nginx创建一个服务。nginx正在添加诸如“x-xss-protection”之类的安全头 当响应返回肯定状态(如200)时,正确发送报头。但是,当我返回错误状态时,所有nginx头都会消失,请求不会通过中间件 app.get('/', (req, res, next) => { res.json(400, { test: 'test', }); }); app.on('restifyError', (req, res, err, cb) =&

我正在用restify+nginx创建一个服务。nginx正在添加诸如“x-xss-protection”之类的安全头

当响应返回肯定状态(如200)时,正确发送报头。但是,当我返回错误状态时,所有nginx头都会消失,请求不会通过中间件

app.get('/', (req, res, next) => {
  res.json(400, {
    test: 'test',
  });
});

app.on('restifyError', (req, res, err, cb) => {
  logger.error(err);
  return cb();
});
客户端错误的响应:

HTTP/1.1 400 Bad Request
Connection: keep-alive
Date: Wed, 11 Nov 2020 21:35:09 GMT
Content-Type: application/json
Content-Length: 17
Server: Nginx
Response-Time: 14
无误响应:

HTTP/1.1 200 OK
Connection: keep-alive
Date: Wed, 11 Nov 2020 21:41:31 GMT
Content-Type: application/json
Content-Length: 17
Server: Nginx
Response-Time: 10
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=63072000; 
X-Content-Type-Options: nosniff
Cache-Control: no-cache, no-store, max-age=0
X-Xss-Protection: 0
Referrer-Policy: strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'; connect-src 'none'; object-src 'none'; media-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; frame-src 'none'; require-trusted-types-for 'script';
Feature-Policy: fullscreen 'self'