Snippets

Brian Medley Attempt to add a specific port to url_for

Created by Brian Medley
#!/opt/perl

use Mojolicious::Lite;

app->hook(after_build_tx => sub {
  my ($tx, $app) = @_;

    $tx->req->on(finish => sub {
        my $msg = shift;

        $msg->parse({HTTP_HOST => "127.0.0.1:12345"});
    });
});

get '/' => sub {
    my $c = shift;

    $c->render(text => $c->url_for("/")->to_abs);
};

app->start;

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.