Files
FongerandGitHub afddb6ebda fix(image): preload should respect referrerPolicy (#49584)
This is a bug fix PR.

We should respect referrerPolicy when preloading a priority next/image

Reproduce codesandbox: https://codesandbox.io/p/sandbox/boring-fog-4o28oi
As you can see, the image still request with `referer` header although we have `referrerPolicy="no-referrer" in img attribute.

<img width="645" alt="image" src="https://github.com/vercel/next.js/assets/5862369/6a2779d3-e0e2-4dfe-80d2-c8a4243f430b">
2023-05-13 20:33:07 +00:00

60 lines
1.2 KiB
JavaScript

import React from 'react'
import Image from 'next/legacy/image'
const Page = () => {
return (
<div>
<p>Priority Page</p>
<Image
priority
id="basic-image"
src="/test.jpg"
width="400"
height="400"
></Image>
<Image
priority
id="basic-image-with-crossorigin"
crossOrigin="anonymous"
src="/test.jpg"
width="400"
height="400"
></Image>
<Image
priority
id="basic-image-with-referrerpolicy"
referrerPolicy="no-referrer"
src="/test.png"
width="400"
height="400"
></Image>
<Image
loading="eager"
id="load-eager"
src="/test.png"
width="400"
height="400"
></Image>
<Image
priority
id="responsive1"
src="/wide.png"
width="1200"
height="700"
layout="responsive"
/>
<Image
priority
id="responsive2"
src="/wide.png"
width="1200"
height="700"
layout="responsive"
/>
<p id="stubtext">This is the priority page</p>
</div>
)
}
export default Page