S3 Bucket CORS Error With Laravel File Upload

Reading Time: < 1 minute

If you get a CORS error when you are uploading to AWS S3 bucket from Laravel, do the following:

  1. Go to the permissions tab of the S3 bucket in AWS
  2. Go to the Cross-origin resource sharing (CORS) section
  3. Enter the JSON object string below and save

[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"http://my-local-site.local"
],
"ExposeHeaders": [
"x-amz-server-side-encryption",
"x-amz-request-id",
"x-amz-id-2"
],
"MaxAgeSeconds": 3000
}
]

The AllowedMethods prop

You can add other HTTP methods here. The PATCH method is not allowed.

The AllowedOrigins prop

Add all the URLs you want to allow.

If this solved your problem or you have any questions, reply in the comments

Afolabi 'aphoe' Legunsen on FacebookAfolabi 'aphoe' Legunsen on GithubAfolabi 'aphoe' Legunsen on GoogleAfolabi 'aphoe' Legunsen on LinkedinAfolabi 'aphoe' Legunsen on TwitterAfolabi 'aphoe' Legunsen on Youtube
Afolabi 'aphoe' Legunsen
Software Project Lead at itquette solutions
A software developer with 9 years professional experience. Over the years, he has built and contributed to a number of projects which includes MoneyTalks that won Visa's Financial Literacy Challenge and Opomulero that won the British Council's Culture Shift III.

He currently the Software Project Lead of Itquette Solutions where his team has built Smart PMS and BlueQuiver HRMS among many other products.

Leave a Comment