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
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Security
3
3
description: Learn about the security defaults and how to further harden your OG image endpoint.
4
4
---
5
5
6
-
Nuxt OG Image ships with secure defaults. Image dimensions are clamped, renders are time limited, internal network requests are blocked, and user provided props are sanitized. No configuration is needed for these protections.
6
+
Nuxt OG Image ships with secure defaults. The module clamps image dimensions, time limits renders, blocks internal network requests, and sanitizes user-provided props. These protections require no configuration.
7
7
8
8
The primary security concern with runtime OG image generation is **denial of service**: without protection, anyone can craft arbitrary image generation requests to your `/_og/d/` endpoint, consuming server CPU and memory. URL signing prevents this by ensuring only your application can generate valid image URLs.
9
9
@@ -36,15 +36,15 @@ Enabling `strict` mode applies all recommended security defaults in a single fla
36
36
37
37
Any of these can still be overridden explicitly. Strict mode only changes the defaults.
38
38
39
-
The build will fail if `strict` is enabled without a `secret`. Generate one with:
39
+
The build will fail if you enable `strict` without a `secret`. Generate one with:
40
40
41
41
```bash
42
42
npx nuxt-og-image generate-secret
43
43
```
44
44
45
45
## URL Signing
46
46
47
-
When a signing secret is configured, every OG image URL includes a cryptographic signature in the path. The server verifies this signature before rendering, rejecting any URL that has been tampered with or crafted manually.
47
+
When you configure a signing secret, every OG image URL includes a cryptographic signature in the path. The server verifies this signature before rendering, rejecting any URL that has been tampered with or crafted manually.
48
48
49
49
This prevents unauthorized image generation requests that would otherwise consume server resources.
-No server-side rendering code is included in your production build
109
-
-Images are generated once at build time and served as static assets
107
+
When you enable zero runtime:
108
+
-Your production build includes no server-side rendering code
109
+
-The build generates images once and serves them as static assets
110
110
- The `/_og` endpoint is not available at runtime
111
111
112
112
If your OG images don't need to change dynamically after deployment, this is the recommended approach.
@@ -157,7 +157,7 @@ If you find yourself passing large amounts of data through query parameters (tit
157
157
158
158
## Restrict Runtime Images to Origin
159
159
160
-
When runtime image generation is enabled, anyone who knows the `/_og` endpoint pattern can request an image directly. The `restrictRuntimeImagesToOrigin` option limits runtime generation to requests whose `Host` header matches your configured site URL.
160
+
When you enable runtime image generation, anyone who knows the `/_og` endpoint pattern can request an image directly. The `restrictRuntimeImagesToOrigin` option limits runtime generation to requests whose `Host` header matches your configured site URL.
The module reads the `Host` header from each runtime request using h3's `getRequestHost` (with `X-Forwarded-Host` support for reverse proxies) and compares it against the host from your [Nuxt Site Config](https://nuxtseo.com/docs/site-config/getting-started/introduction)`url`. If the hosts don't match, the request receives a `403` response.
175
175
176
-
Because the `Host` header is mandatory in HTTP/1.1, this check works with all clients including social media crawlers. No `Origin` or `Referer` header is required.
176
+
Because HTTP/1.1 requires the `Host` header, this check works with all clients including social media crawlers. The server does not need an `Origin` or `Referer` header.
177
177
178
178
### Allowing Additional Origins
179
179
@@ -197,7 +197,7 @@ Prerendering and dev mode bypass the host check entirely.
197
197
198
198
## Debug Mode Warning
199
199
200
-
Enabling `ogImage.debug` in production exposes the `/_og/debug.json` endpoint. The module will log a warning at build time if debug is enabled outside of dev mode. Make sure to disable it before deploying.
200
+
Enabling `ogImage.debug` in production exposes the `/_og/debug.json` endpoint. The module will log a warning at build time if you enable debug outside of dev mode. Make sure to disable it before deploying.
Copy file name to clipboardExpand all lines: docs/content/3.guides/3.runtime-cache.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Runtime Cache
3
3
description: How OG image caching works at runtime, including internal storage, CDN edge caching, and platform integration.
4
4
---
5
5
6
-
When generating images at runtime, Nuxt OG Image provides two layers of caching to minimise server load and response times. For most deployments, the defaults work well and no configuration is needed.
6
+
When generating images at runtime, Nuxt OG Image provides two layers of caching to minimise server load and response times. For most deployments, the defaults work well and require no configuration.
7
7
8
8
## Quick Start
9
9
@@ -50,7 +50,7 @@ That's it. The module handles cache headers, CDN integration, and cache key gene
50
50
51
51
### Layer 1: Internal Cache (Nitro Storage)
52
52
53
-
The module caches rendered image buffers in Nitro storage. On a cache hit, the image is served in ~5-30ms instead of re-rendering (400-3500ms).
53
+
The module caches rendered image buffers in Nitro storage. On a cache hit, Nitro serves the image in ~5-30ms instead of re-rendering (400-3500ms).
54
54
55
55
By default, this uses **in-memory** storage. The cache is lost on server restart or redeployment. Configuring a [persistent storage driver](#persistent-storage) fixes this.
56
56
@@ -83,7 +83,7 @@ The module sets `Cache-Control` on every OG image response so CDNs cache it corr
Where `<ttl>`{lang="html"} is`cacheMaxAgeSeconds` (default 72 hours). URLs are content-addressed (encoded params + component hash), so `immutable` is safe; the response bytes never change for a given URL. No Nitro `swr`/`isr` route rule is needed (and it wouldn't work anyway, as `cachedEventHandler` JSON-serializes responses and breaks binary PNG/JPEG output).
86
+
Where `<ttl>`{lang="html"} means`cacheMaxAgeSeconds` (default 72 hours). URLs use content addressing (encoded params + component hash), so `immutable` is safe; the response bytes never change for a given URL. You do not need a Nitro `swr`/`isr` route rule (and it wouldn't work anyway, as `cachedEventHandler` JSON-serializes responses and breaks binary PNG/JPEG output).
87
87
88
88
## Query Parameters
89
89
@@ -95,7 +95,7 @@ OG image URLs encode all options in the **URL path**, not query parameters:
95
95
96
96
The cache key is deterministic from the path alone. Appending query parameters like `?ref=twitter` or `?utm_source=og` directly to an OG image URL has no effect on rendering. If you need different image variants, use a [custom cache key](#custom-cache-key).
97
97
98
-
Note that your **page URL's** query parameters (e.g., `/products?page=2`) are encoded into the generated OG image URL via the `_query` field. This means different page query strings produce different OG image URLs, since the page may render differently with different query params. Each unique combination gets its own cached image.
98
+
Note that the generated OG image URL encodes your **page URL's** query parameters (e.g., `/products?page=2`) via the `_query` field. This means different page query strings produce different OG image URLs, since the page may render differently with different query params. Each unique combination gets its own cached image.
Append `?purge` to any OG image URL to invalidate its internal cache entry and force a fresh render.
220
220
221
-
When [URL signing](/docs/og-image/guides/security#url-signing) is enabled, you must provide the signing secret as the purge value: `?purge=<your-secret>`{lang="html"}. This prevents unauthorized cache invalidation.
221
+
When you enable [URL signing](/docs/og-image/guides/security#url-signing), you must provide the signing secret as the purge value: `?purge=<your-secret>`{lang="html"}. This prevents unauthorized cache invalidation.
222
222
223
223
Note that this only clears the module's internal Nitro storage cache (Layer 1). CDN edge caches (Layer 2) may continue serving the previous version until their TTL expires. To force CDN re-fetch:
Copy file name to clipboardExpand all lines: docs/content/4.api/0.define-og-image.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ The emoji set to use when generating the image. Set to `false` to disable emoji
82
82
### `html`
83
83
84
84
::deprecated
85
-
The `html` option is deprecated and will be removed in the next major version due to SSRF risk. Use a Vue component instead. This option is disabled when `security.strict`is enabled.
85
+
The `html` option is deprecated and the next major version will remove it due to SSRF risk. Use a Vue component instead. `security.strict`disables this option.
86
86
::
87
87
88
88
- Type: `string`{lang="ts"}
@@ -109,7 +109,7 @@ The number of seconds to cache the image for. This is useful for reducing the nu
109
109
- Type: `string`{lang="ts"}
110
110
- Default: `undefined`{lang="ts"}
111
111
112
-
Custom cache key for this OG image. When set, this key is used directly for caching instead of the auto-generated key.
112
+
Custom cache key for this OG image. When set, the module uses this key directly for caching instead of the auto-generated key.
Copy file name to clipboardExpand all lines: docs/content/6.migration-guide/v6.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,7 +302,7 @@ Query parameters are no longer included in cache keys. Previously, `/page?foo=ba
302
302
303
303
See [PR #427](https://github.com/nuxt-modules/og-image/pull/427).
304
304
305
-
All image options are encoded in the URL path, so query parameters on the OG image URL have no effect. In v5, query parameter overrides (e.g. `?title=Override`) worked in production when URL signing was disabled. In v6, query param overrides are only available in dev and prerender modes. Use `defineOgImage` props to pass dynamic values instead.
305
+
The URL path encodes all image options, so query parameters on the OG image URL have no effect. In v5, query parameter overrides (e.g. `?title=Override`) worked in production without URL signing. In v6, query param overrides only work in dev and prerender modes. Use `defineOgImage` props to pass dynamic values instead.
0 commit comments