Adding alternative hidden service as an option.

This commit is contained in:
sergiotarxz 2023-07-30 15:39:36 +02:00
parent 5dc5a8b97d
commit d64d988140
2 changed files with 13 additions and 0 deletions

View File

@ -5,5 +5,6 @@
"database": "example"
},
"base_url": "https://burguillos.info",
"onion_base_url": "http://example.onion";
"listen": "https:localhost:3555"
}

View File

@ -17,6 +17,18 @@ sub startup ($self) {
}
}
);
$self->hook(
before_render => sub($c, $args) {
my $onion_base_url = $self->config->{onion_base_url};
my $base_url = $self->config->{base_url};
if (!defined $onion_base_url) {
return;
}
my $current_route = $c->url_for;
$current_route =~ s/^$base_url//;
$c->res->headers->header('Onion-Location' => $onion_base_url.$current_route);
}
);
my $config = $self->plugin('JSONConfig');
$self->config(
hypnotoad => { proxy => 1, listen => [$self->config('listen') // 'http://localhost:3000'] } );