Dancer2::Manual::Deployment even mentions such a possibility, so I followed the instructions. I included
to config.yml, and the admin configured the proxy similarly as shown in the manual (see Using-Apache's-mod_proxy of Dancer2::Manual::Deployment.behind_proxy: 1
I was given a prefix under which the app would be running, e.g. https://example.com/prefix/login.
But it doesn't work correctly. For example, the css files are ignored. Or rather, they can't be found.
The main.tt template was created with the following link (part of the initial scaffolding):
<link rel="stylesheet" href="<% request.uri_base %>/css/style.css">
But the request.uri_base doesn't expand to /prefix, it remains empty.
Similarly, I use Dancer2::Plugin::Auth::Tiny for user authentication. Again, I almost copied verbatim the synopsis code:
get '/' => needs login => sub { # ... }; get '/login' => sub { template 'login' }; post '/login' => sub { my $user = body_parameters->get('uname'); if (is_valid($user, body_parameters->get('psw'))) { session(user => $user); redirect('/') } else { template index => {error => 'Wrong username or password'} } };
But again, when I try to open the page, the authentication plugin redirects the browser to /login instead of /prefix/login.
I was able to fix the problems by
<link rel="stylesheet" href="css/style.css">
plugins: Auth::Tiny: login_route: /prefix/login
Mentioning the prefix in the config definitely feels wrong. Hardcoding the prefix into the app? It also means the app can't be run locally on localhost for testing anymore.
How should I properly write the app, configure it, and configure Apache to make it work both locally and in production, without hardcoding the prefix anywhere in the app?
Interestingly, all Python flask and whatever apps written by other colleagues run as written without problems.
In reply to Dancer2 App Deployment through Apache Proxy by choroba
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |