update thumbnail if failed to fetch and return url if already signed

This commit is contained in:
Hongbo Wu 2023-08-10 18:41:10 +08:00
parent f06d2558c2
commit 7bd747601b

View file

@ -1,5 +1,5 @@
import { encode } from 'urlsafe-base64'
import crypto from 'crypto'
import { encode } from 'urlsafe-base64'
import { env } from '../env'
function signImageProxyUrl(url: string): string {
@ -17,6 +17,11 @@ export function createImageProxyUrl(
return url
}
// url is already signed
if (url.startsWith(env.imageProxy.url)) {
return url
}
const urlWithOptions = `${url}#${width}x${height}`
const signature = signImageProxyUrl(urlWithOptions)