File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
gitbook-v2/src/lib/images Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ export function createImageResizer({
66
66
linker . toAbsoluteURL ( linker . toPathInContent ( '/~gitbook/image' ) )
67
67
) ;
68
68
url . searchParams . set ( 'url' , getImageAPIUrl ( urlInput ) ) ;
69
- url . searchParams . set ( 'host' , host ) ;
70
69
71
70
if ( options . width ) {
72
71
url . searchParams . set ( 'width' , options . width . toString ( ) ) ;
Original file line number Diff line number Diff line change @@ -37,16 +37,21 @@ export async function serveResizedImage(request: Request) {
37
37
}
38
38
39
39
// Verify the signature
40
+ const host =
41
+ request . headers . get ( 'x-gitbook-host' ) ??
42
+ request . headers . get ( 'x-forwarded-host' ) ??
43
+ request . headers . get ( 'host' ) ??
44
+ requestURL . host ;
40
45
const verified = await verifyImageSignature (
41
46
{
42
47
url,
43
- host : requestURL . host ,
48
+ host,
44
49
} ,
45
50
{ signature, version : signatureVersion }
46
51
) ;
47
52
if ( ! verified ) {
48
53
return new Response (
49
- `Invalid signature "${ signature ?? '' } " (version ${ signatureVersion } ) for "${ url } " on "${ requestURL . host } "` ,
54
+ `Invalid signature "${ signature ?? '' } " (version ${ signatureVersion } ) for "${ url } " on "${ host } "` ,
50
55
{ status : 400 }
51
56
) ;
52
57
}
You can’t perform that action at this time.
0 commit comments