2

I tried to integrate spatie media library with S3 and cloudfront. But I couldn't get the images to serve through cloudfront cdn.

Basically what I did was to set the AWS_URL to the Cloudfront url but when I check the image url it doesn't have the cloudfront in the url but rather the s3 and region.

Is it because I'm doing something wrong or is it because the package doesn't support this cdn?

apokryfos
  • 38,771
  • 9
  • 70
  • 114
nscode
  • 147
  • 1
  • 9

1 Answers1

1

Taken from this Github issue you can set your s3 disk url to your CF url:

 's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_S3_CLOUDFRONT'),
 ],
codedge
  • 4,754
  • 2
  • 22
  • 38