Search code examples
routesdancer

Dancer route is appending to current route


The route I'd like to generate is:

myapp.com/foo/bar

Once I hit that route, I can, in the same page that is loaded when hitting that route, go to routes such as:

myapp.com/foo/baz
myapp.com/foo/nod
etc

So the route that is used to hit the above is:

get '/foo/:bar' => sub {
    my $dev = param('bar');
    template 'list', { person => $people };
};

In the list.tt template, I have a nav list that points again to this route 'foo/:bar':

<ul class="dropdown-menu" role="menu">
   [% FOREACH person = people%]
         <li><a href="foo/[% person %]">[% person %]</a></li>
   [% END -%]
</ul>

My problem is that when I click on one of those links, I get the following in the URL: 'foo/foo/baz'

Does anyone know why? Should I be explicit when creating my links (i.e. saying href="myapp.com/foo/[% person %]")?


Solution

  • Your links should start with a '/' if you would like to have absolute links.

    like

    <a href="/abc/[% url %]">
    

    HTH