R2 as Image Storage: Images stopped showing

I am using Cloudflare R2 for my react native project to store and display images. I had no problems at all and everything was really great until no images showed up suddenly.

Therefore, I checked older versions of my project but there were no pictures as well. I can assure you, that my app worked perfectly in regards of pictures.

Firstly, my implementation: My Database is saving the unique identifiers of the pictures. With this function all pictureURLs get fetch from Cloudflare. I am using the aws-sdk-v3 to get and put images into R2.

export const getPictureURLs = async (collection: Post[]): Promise<Post[]> => {
  for await (const doc of collection) {
    try {
      const command = new GetObjectCommand({
        Bucket: "<bucket>",
        Key: doc.pictures,
      });
      const url = await getSignedUrl(s3Client, command, { expiresIn: 3600 });
      console.log(url);
      doc["pictureURL"] = url;
    } catch (error) {
      console.error("Error retrieving picture (getPictureURLs): ", error);
    }
  }
  return collection;
};

Also when logging the url to the console I get a link like this: https://<bucket>.<identifier>.r2.cloudflarestorage.com/ED044D21-0F0F-4EBB-B973-BED24393323C?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=<amz-credential>%2F20230505%2Fauto%2Fs3%2Faws4_request&X-Amz-Date=20230505T074529Z&X-Amz-Expires=3600&X-Amz-Signature=<amz-signature>&X-Amz-SignedHeaders=host&x-id=GetObject which seems like the url is still getting retrieved.

When accessing the url in the browser I get an error like so:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
   <Code>Unauthorized</Code>
   <Message>Unauthorized</Message>
</Error>

Here are my dependencies of my react native app:

"react": "18.2.0",
"react-native": "0.71.7",
"aws-sdk": "^2.1347.0",
"@aws-sdk/client-s3": "^3.303.0",
"@aws-sdk/s3-request-presigner": "^3.303.0",

I am quite unsure as of why it stopped working so suddenly and also effected previous builds. I think it may has to do something with an aws-sdk update or a Cloudflare update.

One additional note: I did not change anything in my Cloudflare account or my R2 settings.

I would be really thankful for any help in that regard.

This was a me thing… My API Key expired so every request I was sending was unauthorized.