nscode
nscode

Reputation: 157

laravel spatie/media library serving images from s3 with cloudfront

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?

Upvotes: 3

Views: 2085

Answers (1)

codedge
codedge

Reputation: 5164

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'),
 ],

Upvotes: 3

Related Questions