Question

How to Setup Spaces with Laravel 11

I am not sure if I am missing something with my configuration. Though I have tried many different ways.

AWS_ACCESS_KEY_ID=KEY
AWS_SECRET_ACCESS_KEY=KEY
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=BUCKETNAME
AWS_ENDPOINT=https://nyc3.digitaloceanspaces.com
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_URL=https://BUCKETNAME.nyc3.cdn.digitaloceanspaces.com

This is how it is configured, obviously the keys are set properly and the bucketname is also configured properly. It does attempt to PUT files to the space however they come out like so.

Access to XMLHttpRequest at

https://BUCKETNAME.nyc3.digitaloceanspaces.com/tmp/74Chi8ZPPcXxmqM61jvclJkyxz8y6z-metaU2VydmljZXNfSGVyb18xMjYweDU2MF9EZXNrdG9wX2hlcm8tZGVza3RvcC5qcGVn-.jpeg?x-amz-acl=private&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=PUBKEYAW6H9AKUCLVRCLNJ%2F20240719%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240719T205725Z&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Expires=300&X-Amz-Signature=72c9cdb14903be4409ba9bcd2aa933f0411a1b34c0f5597e07dd9e0dc75f6c36

from origin ‘https://market.test’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

This made me believe that it was related to the CORS configuration on the bucket. So I went in an added my development address. “https://market.test” and set it to have all allowed methods ( this is just for a development env ) and ACM age to 0s.

This didn’t work so I even added the same with the Origins set to *

Anyone have any ideas on what might be able to resolve this?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
July 20, 2024

Hi there,

Can you also share the configuration in your config/filesystems.php?

I could suggest adding 'visibility' => 'public' setting to your filesystem as it will be needed to ensure that the images uploaded via the media manager are visible to the public.

Do you also see any errors in the Laravel error log when you try to upload images?

I usually follow step 1 and step 2 from this guide here on how to configure Laravel with Spaces:

https://devdojo.com/bobbyiliev/how-to-use-digitalocean-spaces-with-laravel-voyager

Regarding your CORS error, would you mind sharing a screenshot of the current CORS configuration that you have?

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.