Is there a way to have urls such as /foo/bar
replaced bay baseurl/foo/bar
for each template rendering?
Absolutely. You can do this with the before_dispatch
hook (or maybe the before_routes
hook) in the Mojolicious::App
object.
app->hook( before_dispatch => sub {
my $c = shift;
unless ($c->req->url->path->to_route =~ m#/baseurl#) {
$c->req->url->path( "/baseurl" . $c->req->url->path->to_string);
}
} );
...
app->start;