[solved] Iron Router - Routes attached to subdirectory instead of root? Why?

Situation

I have three routes:

1.My “home” route, which displays a list of products:

Code:

Router.route('/', function () {
  this.render('products');
  this.layout('layout_products');
});

2.My “products_detail” route, which displays a detaild view of a clicked:

Code:

Router.route('/products_detail/:_id', function () {
   this.render('products_detail', {
      data: function () {
    	return Products.findOne({_id: this.params._id});
      }
    });
   this.layout('layout_products');
});

3.My “my_products_add” route, that displays a form:

Code:

Router.route('/my_products_add', function () {
  this.render('my_products_add');
  this.layout('layout_my_products');
});

Problem

When I visit the “product_detail” route I get an url like this:

http://localhost:3000/products_detail/3PKN2zA3DgZ95Kvs8

That is correct.

NOW when I click on my “my_products_add” route from there, I expect something like this:

http://localhost:3000/my_products_add

But instead I get this:

http://localhost:3000/products_detail/my_products_add

Why is this happening?
How can I fix this?

For some reason I cant seem to find a solution to this although it seems like a pretty simple thing.
Thanks for adivce! :smile:

How do you generate the HTML for the link/button? Apparently you specify the HREF as my_products_add instead as /my_products_add

1 Like

Okay, wow! How simple! :smiley:
Everything works now. Thanks a lot! @jamgold