Skip to content

Commit 5f7ca81

Browse files
committed
1 parent 75ce52a commit 5f7ca81

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

content/faq/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ title: "Frequently asked questions (FAQ)"
1212
- [How do I set both `Content-Security-Policy` and `Content-Security-Policy-Report-Only` headers?](https://github.com/helmetjs/helmet/issues/351#issuecomment-1015498560)
1313
- [How should I use Helmet with non-document responses?]({{< ref "faq/non-documents" >}})
1414
- [How do I disable blocking with the `X-XSS-Protection` header?]({{< ref "faq/x-xss-protection-disable-blocking" >}})
15+
- [How do I enable the `report` directive with the `X-XSS-Protection` header?]({{< ref "faq/x-xss-protection-report-directive" >}})
1516
- [Who made Helmet?]({{< ref "faq/contributors" >}})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: How do I enable the "report" directive with the X-XSS-Protection header?
3+
---
4+
5+
Previous versions of Helmet (and the `x-xss-protection` package) allowed you to add the `report` directive. This functionality was removed because enabling this header is no longer recommended.
6+
7+
If you still need to set a `report` directive for some reason, you can write your own small middleware:
8+
9+
```js
10+
// NOTE: This is discouraged.
11+
app.use((req, res, next) => {
12+
res.setHeader("X-XSS-Protection", "1; mode=block; report=/report-path");
13+
next();
14+
});
15+
```

0 commit comments

Comments
 (0)