Debugging AWS S3 for Rails Active Storage

Tech WebDev Rails

It could be your CORS configuration for AWS S3 for Rails ActiveStorage

If you've gotten to the point where you can add an upload to Active Storage but then the items somehow disappear, it's probably your CORS configuration that's wrong. 

Credit to Mike Rogers for helping me get the right CORS settings here — 

This is what you'll need to toss into your CORS settings for your AWS bucket 

<pre>
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
</pre>


Similar Posts

Spinning Up a New Rails App

Bookmarking this incredible tool

WebDev Rails

Refactoring Rails: Use REST

Just some notes / key takeaways from the course "Refactoring Rails" by the great Ben Orenstein.

WebDev Rails

Refactoring Rails: Form Objects

Form objects let you work with many objects at once in rails. It's a pattern that's a lot more powerful and clean than accepts_nested_attributes.

WebDev Rails