New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveStorage unable to render attachment URLs across subdomains #32129
Comments
This was introduced in the Commit Provide a sensible default host 6fb3ac1 The problem is, with setting host to "localhost" you don't get relative URLs. But relative URLs for the Disk Storage Adapter are fine. And there is a second BUG: When you set another host in the yml file, AS will ignore the setting. I'ts always "localhost". |
@42he when you say that AS ignores the setting, is that the generated url is using 'localhost' but |
I have the mirror service: local: irb(main):001:0> ActiveStorage::Blob.service.host The links all start with localhost:3000 I don't know if it setted the host correct before your commit, but with no host setting i got "relative" URLS witch worked perfekly fine. |
@42he what do you get if you do I think what you may be seeing is the stable url in the view which then gets redirected to the service url by the ActiveStorage::BlobsController#show action. |
The latest fix for this, ccac681, breaks any non-browser direct upload clients. e.g., an iOS or Android native client as the direct upload Is there a reason to not allow the host option? Is there something different that non-browser ActiveStorage clients should be doing? |
I am developing a mutli-subdomain application, and because of that I utilize
lvh.me
as my host to be able to navigate those subdomains locally.As of 6fb3ac1 on the ActiveStorage Disk service, the host was defaulted to
localhost:3000
which forces me to set the host: setting in myconfig/storage.yml
I would expect that attached images would be able to look at the current environment's server and build the url from there. I would expect that if I upload an image on
admin.lvh.me:5000
, it would be able to render onlvh.me:5000
Because I have to explicity set the host, the generated image urls are only available on the subdomain I specify in the
config/storage.yml
With the configuration as seen above, when I am on the
admin
subdomain I receive this error when displaying an attached imageWithout anyway to dynamically set that ActiveStorage url host, I'm not sure how to get around this issue.
Ruby: 2.4.2
Rails: 5.2.0.rc1
The text was updated successfully, but these errors were encountered: