Unverified Commit f00fcc90 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

[backport]: fix(next/image): fix image-optimizer.ts headers (#82114) (#82175)

Backports:
- #82114
Co-authored-by: 's avatarSteven <steven@ceriously.com>
parent 55a7568e
...@@ -634,7 +634,6 @@ export async function fetchInternalImage( ...@@ -634,7 +634,6 @@ export async function fetchInternalImage(
const mocked = createRequestResponseMocks({ const mocked = createRequestResponseMocks({
url: href, url: href,
method: _req.method || 'GET', method: _req.method || 'GET',
headers: _req.headers,
socket: _req.socket, socket: _req.socket,
}) })
......
const pixel =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg=='
export default function handler(req, res) {
if (req.headers['cookie']) {
res.setHeader('content-type', 'image/png')
res.end(Buffer.from(pixel, 'base64'))
} else {
res.status(401).end('cookie was not found')
}
}
...@@ -308,6 +308,13 @@ export function runTests(ctx: RunTestsCtx) { ...@@ -308,6 +308,13 @@ export function runTests(ctx: RunTestsCtx) {
expect(ctx.nextOutput).toContain(animatedWarnText) expect(ctx.nextOutput).toContain(animatedWarnText)
}) })
it('should not forward cookie header', async () => {
const query = { w: ctx.w, q: 30, url: '/api/conditional-cookie' }
const opts = { headers: { accept: 'image/webp', cookie: '1' } }
const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, opts)
expect(res.status).toBe(400)
})
if (ctx.nextConfigImages?.dangerouslyAllowSVG) { if (ctx.nextConfigImages?.dangerouslyAllowSVG) {
it('should maintain vector svg', async () => { it('should maintain vector svg', async () => {
const query = { w: ctx.w, q: 90, url: '/test.svg' } const query = { w: ctx.w, q: 90, url: '/test.svg' }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment