title: How to render template in route with params in Express?
body: <p>I am using Express and Pug template engine. I have two routes:</p>
  
  <p><strong>/profile</strong> which shows logged in user profile info. Can be accessed only by logged in users </p>
  
  <p><strong>/profile/:id</strong> which shows other user's info. Can be accessed by everyone. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>    app.get("/profile/:id", function(req,res) {
        // Get info from DB for specifed username in req.params.id
        res.render("profile.pug", locals);
      });
  
      app.get("/profile", isLoggedIn, function(req,res) { // isLoggedIn is middleware which checks if user is logged in
        res.render("profile.pug", locals);
      });
  </code></pre>
  
  <p>I serve my JS/CSS/images using express.static:</p>
  
  <pre><code>app.use(express.static(__dirname+"/public"));
  </code></pre>
  
  <p>When I browse <strong>/profile</strong>, everything is OK, but when I try <strong>/profile/:id,</strong> it renders template without styles. Morgan loggger wrote that <strong>/profile/:id</strong> tries to get assets not from domain root, but from /profile!</p>
  
  <pre><code>GET /profile/css/bootstrap.css 404 7.352 ms
  </code></pre>
  
  <p>Which should be:</p>
  
  <pre><code>GET /css/bootstrap.css 200 7.352 ms
  </code></pre>
  
  <p>How to fix that?</p>