R2 Configuration

At the moment, the only way to upload images is to configure R2. It's free.

New Bucket

Go over the CloudFlare, register, and head to the R2 page.

Create a new Bucket.

  • Choose Automatic
  • Choose Standard

Copy the information respectfully into your .env environment.

CLOUDFLARE_ACCOUNT_ID="accountId"
CLOUDFLARE_ACCESS_KEY="accessKey"
CLOUDFLARE_SECRET_ACCESS_KEY="secretAccessKey"
CLOUDFLARE_BUCKETNAME="bucketName"
CLOUDFLARE_REGION="region (like wnam)"

Custom Domain and CORS policies

Go to configuration and connect a custom domain (if you don't have one, you can use the one that CloudFlare provides.) Add it to your .env file.

CLOUDFLARE_BUCKET_URL="https://customdomain.com"

Click to edit the CORS policy and add the following JSON:

[
  {
    "AllowedOrigins": [
      "http://localhost:4200",
      "https://yourDomain.com",
    ],
    "AllowedMethods": [
      "GET",
      "POST",
      "HEAD",
      "PUT",
      "DELETE"
    ],
    "AllowedHeaders": [
      "Authorization",
      "x-amz-date",
      "x-amz-content-sha256",
      "content-type"
    ],
    "ExposeHeaders": [
      "ETag",
      "Location"
    ],
    "MaxAgeSeconds": 3600
  }
]