You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/3.guides/13.security.md
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,22 @@ The primary security concern with runtime OG image generation is **denial of ser
9
9
10
10
For full protection, we recommend combining URL signing with a **web application firewall** (WAF) or rate limiting on the `/_og/` path prefix. Services like [Cloudflare](https://cloudflare.com), AWS WAF, or your hosting provider's built-in rate limiting can add an additional layer of defense.
11
11
12
+
```bash [.env]
13
+
NUXT_OG_IMAGE_SECRET=<your-secret>
14
+
```
15
+
12
16
```ts [nuxt.config.ts]
13
17
exportdefaultdefineNuxtConfig({
14
18
ogImage: {
15
19
security: {
16
20
strict: true,
17
-
secret: process.env.OG_IMAGE_SECRET,
18
21
}
19
22
}
20
23
})
21
24
```
22
25
26
+
The secret is automatically picked up from the `NUXT_OG_IMAGE_SECRET` environment variable.
27
+
23
28
## Strict Mode
24
29
25
30
Enabling `strict` mode applies all recommended security defaults in a single flag:
@@ -51,13 +56,19 @@ This prevents unauthorized image generation requests that would otherwise consum
51
56
npx nuxt-og-image generate-secret
52
57
```
53
58
54
-
2. Set the environment variable and reference it in your config:
59
+
2. Set the environment variable:
60
+
61
+
```bash [.env]
62
+
NUXT_OG_IMAGE_SECRET=<your-secret>
63
+
```
64
+
65
+
Alternatively, you can set the secret directly in your nuxt config:
Copy file name to clipboardExpand all lines: docs/content/4.api/3.config.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -188,12 +188,15 @@ Security limits for image generation. See the [Security Guide](/docs/og-image/gu
188
188
-**`restrictRuntimeImagesToOrigin`**: Restrict runtime image generation to requests whose `Host` header matches allowed hosts. Default `false`. See the [Security Guide](/docs/og-image/guides/security#restrict-runtime-images-to-origin) for details.
189
189
-**`strict`**: Enable strict security mode. Requires `secret`, disables the deprecated `html` option, defaults `maxQueryParamSize` to `2048`, and enables `restrictRuntimeImagesToOrigin`. Default `false`. See the [Security Guide](/docs/og-image/guides/security#strict-mode) for details.
logger.warn('`ogImage.debug` is enabled in production. This exposes the `/_og/debug.json` endpoint and should not be enabled in production. Disable it before deploying.')
0 commit comments