fix(MoreStickers): CORS bug (#73)

* fix(MoreStickers): Animation Stickers

* fix(MoreStickers): some stickers can't be sent because of CORS bug in Chrome.
This commit is contained in:
leko 2024-10-23 07:47:18 +08:00 committed by GitHub
parent 9d31150927
commit 20996959ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -134,8 +134,9 @@ export async function sendSticker({
file = await toGIF(sticker.image, ffmpegState.ffmpeg); file = await toGIF(sticker.image, ffmpegState.ffmpeg);
} }
else { else {
const response = await fetch(sticker.image, { cache: "force-cache" }); const url = new URL(sticker.image);
// const blob = await response.blob(); url.searchParams.set("t", Date.now().toString()); // To prevent caching, in order to avoid CORS bug in Chrome
const response = await fetch(sticker.image);
const orgImageUrl = URL.createObjectURL(await response.blob()); const orgImageUrl = URL.createObjectURL(await response.blob());
const processedImage = await resizeImage(orgImageUrl); const processedImage = await resizeImage(orgImageUrl);