Open PJ-DSI-DevOps opened 3 years ago
Hello,
When using this plugin behind a reverse proxy with path, the urls generated by "url_for" doesn't work as expected anymore. We end up having a path that look like /{LANG}/{PATH}/foo instead of /{PATH}/{LANG}/foo.
The method used to set the reverse proxy path is taken from this blog post : https://mojolicious.io/blog/2019/03/18/reverse-proxy-with-path/
Here is a small app to reproduce the problem :
use Mojolicious::Lite -signatures; plugin I18N => {namespace => 'MyApp::I18N', support_url_langs => [qw(en fr)]}; if ( my $path = $ENV{MOJO_REVERSE_PROXY} ) { my @path_parts = grep /\S/, split m{/}, $path; app->hook( before_dispatch => sub ($c) { my $url = $c->req->url; my $base = $url->base; push @{ $base->path }, @path_parts; $base->path->trailing_slash(1); $url->path->leading_slash(0); }); } get '/' => sub ($c) { $c->render(text => $c->url_for('/foo')); }; app->start;
Then :
MOJO_REVERSE_PROXY="/myapp" ./base_i18n.pl get /fr/ /fr/myapp/foo
And i was expecting /myapp/fr/foo.
Hello,
When using this plugin behind a reverse proxy with path, the urls generated by "url_for" doesn't work as expected anymore. We end up having a path that look like /{LANG}/{PATH}/foo instead of /{PATH}/{LANG}/foo.
The method used to set the reverse proxy path is taken from this blog post : https://mojolicious.io/blog/2019/03/18/reverse-proxy-with-path/
Here is a small app to reproduce the problem :
Then :
And i was expecting /myapp/fr/foo.