From 74faea3fde14fea5326ceaf6e3d0b94e837067bd Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sun, 17 Jun 2018 11:37:19 -0500 Subject: [PATCH] improvement for dev server --- run-dev | 19 +++++++++++++++++++ static-app.psgi | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/run-dev b/run-dev index da1acf09aa..f0162f06bc 100755 --- a/run-dev +++ b/run-dev @@ -1,5 +1,24 @@ #!/bin/bash +while [[ $# -gt 0 ]]; do + case "$1" in + --suffix) + METACPAN_WEB_CONFIG_LOCAL_SUFFIX="$2" + export METACPAN_WEB_CONFIG_LOCAL_SUFFIX + shift + ;; + --suffix=*) + METACPAN_WEB_CONFIG_LOCAL_SUFFIX="${1:9}" + export METACPAN_WEB_CONFIG_LOCAL_SUFFIX + ;; + *) + echo "Unsupported option $1" >&2 + exit 1 + ;; + esac + shift +done + export METACPAN_WEB_PORT=5001 export PLACK_ENV=development export COLUMNS="$(tput cols)" diff --git a/static-app.psgi b/static-app.psgi index c8b393b5a7..1ba0973b99 100644 --- a/static-app.psgi +++ b/static-app.psgi @@ -10,5 +10,17 @@ my $port = $ENV{METACPAN_WEB_PORT} || 5001; builder { enable '+MetaCPAN::Middleware::Static' => root => $root_dir; - mount '/' => Plack::App::Proxy->new(remote => "http://localhost:$port")->to_app; + 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, + )->to_app; };