I am using DigitalOcean Spaces to store images uploaded via
ActiveStorage. This works great. I have now created a CDN (via DigitalOcean) which I’d like to put in front of my images.
My goal is for links in my ActionText to use the CDN (e.g. https://cdn.myapp.com/image-goes-here.png) rather than
/rails/representations/etc links which hit my app, but I’m finding it rather unclear whether this is possible. I found this comment buried on a Rails pull request:
However, what this appears to do is replace the host name in the URLs but not the path (
/rails/representations is still in the path which doesn’t work for my CDN). I could take this and hack it to remove the Rails-specific paths but this feels really dirty and wrong.
Has anyone managed to do this before and is it even possible? I’d love some advice. It feels like something that should be baked into Rails at some point.