mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This PR modifies Image behavior to require `images.localPatterns.search`
value when used with search queries in the `src` property:
```jsx
// Error
<Image src="/api/user?id=1" width="50" height="50" />
```
```ts
// next.config.ts
export default {
images: {
localPatterns: [
{
pathname: '/api/user',
// Either set explicit query string or leave undefined to match all
search: '?v=2',
},
],
},
}
```
It is to prevent malicious actors like Denial of Wallet (DoW) attacks
and strictly match the search queries for image optimization.
The deprecation warning was added at
https://github.com/vercel/next.js/pull/82627
---------
Co-authored-by: Steven <[email protected]>
7 lines
204 B
TypeScript
7 lines
204 B
TypeScript
import Image from 'next/image'
|
|
|
|
export default function Page() {
|
|
// src with query without localPatterns will throw an error
|
|
return <Image src="/test.png?v=1" alt="test" width={100} height={100} />
|
|
}
|