Skip to content

Commit bfb8cc7

Browse files
styfleztanner
andauthored
chore(docs): mention behavior of redirects and remotePatterns (#91151)
Some users have been confused by the relationship of `images.remotePatterns` and `images.maximumRedirects` so lets document it. This behavior is expected since you might allowlist something like `https://github.com/styfle.png` and that can redirect to whatever it needs to redirect to (assuming maximumRedirects > 0). For example, it currently redirects to `https://avatars.githubusercontent.com/u/229881?v=4` but you can imagine in the future if the redirect was changed, you wouldn't want your app to break. Regardless of redirects, the final response must be an image. --------- Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
1 parent 19a19a3 commit bfb8cc7

File tree

1 file changed

+4
-0
lines changed
  • docs/01-app/03-api-reference/02-components

1 file changed

+4
-0
lines changed

docs/01-app/03-api-reference/02-components/image.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ module.exports = {
608608

609609
The example above will ensure the `src` property of `next/image` must start with `https://assets.example.com` and must have the exact query string `?v=1727111025337`. Any other protocol or query string will respond with `400` Bad Request.
610610

611+
Note that any allowed `remotePatterns` that respond with a redirect will follow the redirect from the remote image server without validating `remotePatterns` again on the redirect location. You can reduce or disable redirects by configuring [maximumRedirects](#maximumredirects).
612+
611613
#### `loaderFile`
612614

613615
`loaderFiles` allows you to use a custom image optimization service instead of Next.js.
@@ -827,6 +829,8 @@ module.exports = {
827829
}
828830
```
829831

832+
For your convenience, these redirects do not need to satisfy [remotePatterns](#remotepatterns).
833+
830834
You can configure the number of redirects to follow when fetching remote images. Setting the value to `0` will disable following redirects.
831835

832836
```js filename="next.config.js"

0 commit comments

Comments
 (0)