CORS issue with Rails app and AWS Cloudfront(?)

I am running a Rails app I transferred from Heroku. I’m using ActiveStorage and my images are uploaded to and served from AWS S3 via AWS Cloudfront. I’m using the rack-cors gem and an initializer that includes all my origins (the Rails app on fly.io as well as the Cloudfront CDN) – however I am still getting CORS errors from time to time (I think for assets that are not cached yet?)
Strangely I don’t remember running into this issue when the app was on Heroku.

Does anyone have hints pointing me in the right direction here or is willing to troubleshoot with me?

I’m “hard”-setting access-control-allow-origin directly in Cloudfront via a policy now – that seems to work and is sufficient for me.

1 Like