R2 public bucket 404

I’ve got a bucket set to allow public access and connected to a subdomain.

I use aws-sdk to upload images to the bucket using the following code:

app.post('/upload2, MuiltiPartyMiddleware, async (req, res) => {
const TempFile = req.files.upload
const p = ‘media/frettamyndir2/’
console.log(req.files.File)
console.log(TempFile[0])

const promise = fs.promises.readFile(path.join(TempFile.path))

const imageBuffer = await Promise.resolve(promise)

try {
var params = {
Bucket: ‘blika-static’,
Key: TempFile.originalFilename,
Body: imageBuffer,
}

s3.upload(params, (err, data) => {
  console.log(err, data)
})
console.log(TempFile.originalFilename)

const link = 'https://static.blika.is/'+TempFile.originalFilename
console.log('https://static.blika.is/'+p+TempFile.originalFilename)
res.status(200).send({ uploaded: true, url: link })

} catch (error) {
res.status(500).send()
}
})

The image is sucessfully uploaded as hown on the Cloudflare dashboard, and I can download it from there, but whenever I try to access it from the subdomain via subdomain/filename it gives me a 404 error that says You are not authorized to view this object.

The weird thing is that sometimes it works, but other times I get the 404 error. Any idea what could be causing this?

hey sveinngauti, I also encounter this issue. Any update?