Skip to content

How to render a custom template for 403 page #2210

Answered by usr345
usr345 asked this question in Q&A
Discussion options

You must be logged in to vote
app->routes->add_condition(auth => sub {
    my ($route, $c, $captures, $num) = @_;

    $c->res->code(403);
    $c->rendered(403);
    $c->render(template => "403"); # <-- adding this helped
    # Here, you could define your condition. For example, check if a parameter is set.
    return 0;  # true/false depending on parameter
});

Yes, it worked.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@usr345
Comment options

Answer selected by usr345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2209 on November 19, 2024 15:54.