Restify会忽略有关错误的Nginx标头

问题描述

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

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

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

app.on('restifyError',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'

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...