title: Route endpoint is not routing, getting a reference error
body: <p>My web application, a url shortener, is not routing to the page when check to see if a user is logged in or not.</p>
  <p>The route should:
  filter the entire list in the urlDatabase by comparing the userID with the logged-in user's ID. And only list urls if the user is logged in.</p>
  <pre><code> app.get('/urls', (req, res) =&gt; {
    let templateVars = {
      urls: urlsForUser(req.cookies.user_id, urlDatabase),
      user: users[req.cookies.user_id],
    };
    res.render(&quot;urls_index&quot;, templateVars);
   });
  </code></pre>
  <p>when I try to access the endpoint I get</p>
  <pre><code>&lt; ReferenceError: /vagrant/w3/tinyapp/views/urls_index.ejs:11
      9| &lt;/head&gt;
      10| &lt;body&gt;
   &gt;&gt; 11|   &lt;%- include('partials/_header') %&gt;
      12|   &lt;main style=&quot;margin: 1em;&quot;&gt;
      13|     &lt;h3&gt;My URLs&lt;/h3&gt;
      14|     &lt;table class=&quot;table&quot;&gt;
  
  /vagrant/w3/tinyapp/views/partials/_header.ejs:13
      11|       &lt;/div&gt;
      12|     &lt;/div&gt;
   &gt;&gt; 13|     &lt;% if(!user_id) { %&gt;
      14|           &lt;a class=&quot;nav-item nav-link&quot; href=&quot;/register&quot; style=&quot;background-color: white; margin: 10px&quot;&gt;Register&lt;/a&gt;                 
      15|           &lt;a class=&quot;nav-item nav-link&quot; href=&quot;/login&quot; style=&quot;background-color: white; margin: 10px&quot;&gt;Login&lt;/a&gt;     
      16|     &lt;% } else { %&gt;
  
  user_id is not defined
      at eval (/vagrant/w3/tinyapp/views/partials/_header.ejs:12:8)
      at _header (/vagrant/w3/tinyapp/node_modules/ejs/lib/ejs.js:691:17)
      at include (/vagrant/w3/tinyapp/node_modules/ejs/lib/ejs.js:689:39)
      at eval (/vagrant/w3/tinyapp/views/urls_index.ejs:12:17)
      at urls_index (/vagrant/w3/tinyapp/node_modules/ejs/lib/ejs.js:691:17)
      at tryHandleCache (/vagrant/w3/tinyapp/node_modules/ejs/lib/ejs.js:272:36)
      at View.exports.renderFile [as engine] (/vagrant/w3/tinyapp/node_modules/ejs/lib/ejs.js:489:10)
      at View.render (/vagrant/w3/tinyapp/node_modules/express/lib/view.js:135:8)
      at tryRender (/vagrant/w3/tinyapp/node_modules/express/lib/application.js:640:10)
      at Function.render (/vagrant/w3/tinyapp/node_modules/express/lib/application.js:592:3)
  </code></pre>
  <p>my header code is:</p>
  <pre><code>&lt;header&gt;
    &lt;nav class=&quot;navbar navbar-expand-md navbar-dark bg-success&quot;&gt;
      &lt;a class=&quot;navbar-brand&quot; href=&quot;/urls&quot;&gt;TinyApp&lt;/a&gt;
      &lt;button class=&quot;navbar-toggler&quot; type=&quot;button&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#navbarNavAltMarkup&quot; aria-controls=&quot;navbarNavAltMarkup&quot; aria-expanded=&quot;false&quot; aria-label=&quot;Toggle navigation&quot;&gt;
        &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt;
      &lt;/button&gt;
      &lt;div class=&quot;collapse navbar-collapse&quot;&gt;
        &lt;div class=&quot;navbar-nav&quot;&gt;
          &lt;a class=&quot;nav-item nav-link&quot; href=&quot;/urls&quot;&gt;My URLs&lt;/a&gt;
          &lt;a class=&quot;nav-item nav-link&quot; href=&quot;/urls/new&quot;&gt;Create New URL&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;% if(!user_id) { %&gt;
            &lt;a class=&quot;nav-item nav-link&quot; href=&quot;/register&quot; style=&quot;background-color: white; margin: 10px&quot;&gt;Register&lt;/a&gt;                 
            &lt;a class=&quot;nav-item nav-link&quot; href=&quot;/login&quot; style=&quot;background-color: white; margin: 10px&quot;&gt;Login&lt;/a&gt;     
      &lt;% } else { %&gt;
        &lt;form class=&quot;form-inline&quot; action=&quot;/logout&quot; method=&quot;POST&quot;&gt;
          &lt;div class=&quot;form-group mb-2&quot;&gt;
            &lt;label for=&quot;name&quot;&gt;&lt;b&gt;Logged in as &lt;%= user_id[&quot;email&quot;] %&gt;&lt;/b&gt;&lt;/label&gt;
            &lt;button type=&quot;logout&quot; class=&quot;btn btn-primary&quot; href=&quot;/logout&quot;&gt;Logout&lt;/button&gt;
          &lt;/div&gt;
        &lt;/form&gt;
      &lt;% } %&gt;
    &lt;/nav&gt;
  &lt;/header&gt;
  
  ````
  </code></pre>