For Workes & Pages, what is the name of the domain?
What is the issue or error you’re encountering
I’ve been using image api for my web app to upload user’s images. I’m using one-time upload URL but somehow now the api returns same upload URL(same id) every time I request. I’ve changed api key and the id had been changed once, but after that still returns same URL. Heres are my code. export async function getUploadUrl() { const response = await fetch( https://api.cloudflare.com/client/v4/accounts/${process.env.NEXT_PUBLIC_CLOUDFLARE_ACCOUNT_ID}/images/v2/direct_upload, { method: “POST”, headers: { Authorization: Bearer ${process.env.NEXT_PUBLIC_CLOUDFLARE_API_KEY}, }, } ); const data = await response.json(); console.log(data); return data; }
export async function getUploadUrl() {
const response = await fetch( https://api.cloudflare.com/client/v4/accounts/${process.env.NEXT_PUBLIC_CLOUDFLARE_ACCOUNT_ID}/images/v2/direct_upload,
{
method: “POST”,
headers: {
Authorization: Bearer ${process.env.NEXT_PUBLIC_CLOUDFLARE_API_KEY},
},
}
);
const data = await response.json();// here I only get same result.id
return data;
}
*result
{
result: {
id: ‘some same ID’,
uploadURL: ‘https://upload.imagedelivery.net/{MyID}/{same as id}’
},
success: true,
errors: ,
messages:
}
and uploading image function
for (const [index, preview] of previews.entries()) { //previews has has id and uploadURL and file
const cloudflareForm = new FormData();
cloudflareForm.append("file", preview.file);
const response = await fetch(uploadUrls[index], {
method: "post",
body: cloudflareForm,
});
if (response.status !== 200) {
return;
}
uploadedImageUrls.push(`https://imagedelivery.net/{MYID}/${preview.id}/public`);
}