Subject: | Dancer::Plugin::Assets does not support arbitrary mountpoints for applications |
I have an application running on http://localhost:5000, mounted at
"/foo" by a Plack script (actual mountpoint changed to protect the
innocent).
Dancer::Plugin::Assets does not seem to be aware of mountpoints, and
builds URLs assuming the application is mounted at "/", so I get
http://localhost:5000/static/minified.css
instead of
http://localhost:5000/foo/static/minified.css
which of course causes 404s all over the place.
This can be fixed by using Dancer's own URI-building functions, so
my $url = _url( $setting->{url} );
would become
my $url = request->uri_for( _url( $setting->{url} ) );
and the _url sub would only contain the logic for making sure there
are no double slashes in the resulting path. _site_url, _scheme and
_host would no longer be needed.
In the meantime, this can be sort of worked around by putting the
mountpoint in the plugin's configuration, but this is awkward since
mountpoints are not actually part of the app's configuration in theory
(a properly portable app should not care about where its mountpoint
is).