Skip to content

Commit e86e51f

Browse files
authoredDec 30, 2024··
Fix an issue where the redirects of potentially malicious images were not going through. (#2666)
1 parent db74ea3 commit e86e51f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

‎.changeset/fuzzy-crabs-argue.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': minor
3+
---
4+
5+
Fix an issue where the redirects of potentially malicious images were not going through.

‎packages/gitbook/src/app/(global)/~gitbook/image/route.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NextRequest } from 'next/server';
1+
import { NextRequest, NextResponse } from 'next/server';
22

33
import {
44
CURRENT_SIGNATURE_VERSION,
@@ -45,7 +45,7 @@ export async function GET(request: NextRequest) {
4545
}
4646

4747
if (signatureVersion !== CURRENT_SIGNATURE_VERSION) {
48-
return Response.redirect(url, 302);
48+
return NextResponse.redirect(url, 302);
4949
}
5050

5151
// Cloudflare-specific options are in the cf object.
@@ -92,7 +92,7 @@ export async function GET(request: NextRequest) {
9292
return response;
9393
} catch (error) {
9494
// Redirect to the original image if resizing fails
95-
return Response.redirect(url, 302);
95+
return NextResponse.redirect(url, 302);
9696
}
9797
}
9898

0 commit comments

Comments
 (0)
Please sign in to comment.