smpallen99 / ex_admin

ExAdmin is an auto administration package for Elixir and the Phoenix Framework
MIT License
1.2k stars 275 forks source link

Link to static content using static_path rahter than static_url #447

Closed haakonst closed 5 years ago

haakonst commented 5 years ago

I'm developing an application that responds to requests on multiple host names having several different subdomain names under the same main (second-level) domain (for example customer-a.example.org, customer-b.example.org, customer-c.example.org). The setup is described in this blog post: https://blog.gazler.com/blog/2015/07/18/subdomains-with-phoenix/. However, the application does not respond to requests on the main (second-level) domain name (in this example: example.org).

Since ExAdmin links to static resources (JavaScript and CSS) used by the templates active_admin.html.eex and admin_lte2.html.eex by using the function static_url, these resources fail to load in my application. The generated links don't include the subdomain name, like this:

https://example.org/css/admin_lte2-4b903242aada0f319f0e076944273dfc.css?vsn=d https://example.org/js/jquery.min-cfb4c11ee8b6c29969a2a615604d49f9.js?vsn=d

Is there a reason why static_url is used rather than static_path? This PR suggests switching to using static_path which would be really helpful for applications using subdomains in this way.