forked from metacpan/metacpan-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
static-app.psgi
38 lines (34 loc) · 882 Bytes
/
static-app.psgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use strict;
use warnings;
use Plack::Builder;
use Plack::App::Proxy;
use File::Basename;
use Config::ZOMG ();
my $root_dir; BEGIN { $root_dir = File::Basename::dirname(__FILE__); }
use lib "$root_dir/lib";
my $port = $ENV{METACPAN_WEB_PORT} || 5001;
my $config = Config::ZOMG->open(
name => 'MetaCPAN::Web',
path => $root_dir,
);
builder {
enable '+MetaCPAN::Middleware::Static' => (
root => $root_dir,
config => $config,
dev_mode => 1,
);
enable sub {
my ($app) = @_;
sub {
my ($env) = @_;
$env->{HTTP_X_FORWARDED_HTTPS} = 'ON'
if $env->{'psgi.url_scheme'} eq 'https';
$app->($env);
};
};
mount '/' => Plack::App::Proxy->new(
remote => "http://localhost:$port",
preserve_host_header => 1,
backend => 'LWP',
)->to_app;
};