sukria/Dancer — Issue #704: request->uri_for & request->port breaks when running behind proxy
Author: Wu-Wu
Created: 2011-11-27 21:38:28+00:00
State: open

In case of dancer app is running behind the proxy and we want to use `request->port` or `request->uri_for` they all breaks and return wrong values.

#!/usr/bin/env perl

use strict;
use Dancer;

set behind_proxy => 1;

get '/foo' => sub {
'scheme : ' . request->scheme . "\n" .
'port : ' . request->port . "\n" .
'base : ' . request->base . "\n" .
'uri_for : ' . request->uri_for('/bar') . "\n" .
};

dance;

Run this app behind proxy and try to GET `https://app.example.com:460/foo`. Result will look like this:

scheme : https
port : 3000
base : https://app.example.com/
uri_for : https://app.example.com/bar

If `X-Frowarded-*` headers were correctly passed to backend.

There's another side effect - it completely breaks the `redirect` if we want to redirect to the same server.