ned4770
ned4770
CDCloudflare Developers
Created by ned4770 on 1/19/2024 in #workers-help
Worker is not resizing
I have tried simplified version, by forcing the quality, but still no success:
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
let url = new URL(request.url)

let options = { cf: { image: {quality: 40} } }

const imageURL = url.searchParams.get("image")
if (!imageURL) return new Response('Missing "image" value', { status: 400 })
const imageRequest = new Request(imageURL, {
headers: request.headers
})

return await fetch(imageURL, options);
}
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
let url = new URL(request.url)

let options = { cf: { image: {quality: 40} } }

const imageURL = url.searchParams.get("image")
if (!imageURL) return new Response('Missing "image" value', { status: 400 })
const imageRequest = new Request(imageURL, {
headers: request.headers
})

return await fetch(imageURL, options);
}
3 replies