title: "TypeError: Cannot read property 'replace' of undefined"
body: <p>I have been trying to make my first express application and I have been getting a error with range.replace() and I tried searching for a fix and I couldn't find one
  This accured while I was trying to stream video.
  And this is my first time using express so ignore the html scripts at the app.send() :)</p>
  <p>My code is:</p>
  <pre class="lang-js prettyprint-override"><code>const express = require('express');
  const app = express();
  const fs = require('fs')
  const path = require('path')
  require('dotenv').config();
  const { auth, requiresAuth } = require('express-openid-connect');
  
  app.use(
      auth({
          authRequired: false,
          auth0Logout: true,
          issuerBaseURL: process.env.ISSUER_BASE_URL,
          baseURL: process.env.BASE_URL,
          clientID: process.env.CLIENT_ID,
          secret: process.env.SECRET,
      })
  );
  
  app.get('/profil', requiresAuth(), (req, res) =&gt; {
      const profileJSON = JSON.stringify(req.oidc.user);
      var obj = JSON.parse(profileJSON);
      function emailVerified(){
          if (obj.email_verified == &quot;true&quot;){
              return &quot;Doğrulandı&quot;;
          }
          else {
              return &quot;Doğrulanmadı&quot;;
          }
      }
      res.send(
          `
          &lt;!DOCTYPE html&gt;
          &lt;head&gt;
              &lt;title&gt;Profil sayfası&lt;/title&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;h1&gt;${obj.nickname}&lt;/h1&gt;
              &lt;img src=&quot;${obj.picture}&quot;&gt;&lt;/img&gt;
              &lt;h2&gt;Gerçek isim: ${obj.name}&lt;/h2&gt;
              &lt;h2&gt;E-posta: ${obj.email}&lt;/h2&gt;
              &lt;h2&gt;E-Posta Doğeulanma Durumu: ${obj.email_verified}&lt;/h2&gt;
              &lt;h2&gt;Ülke: ${obj.locale}&lt;h2&gt;
          &lt;/body&gt;
          `
      );
  })
  
  
  app.get('/', (req, res)=&gt;{
      res.send(req.oidc.isAuthenticated() ? `
      &lt;!DOCTYPE html&gt;
      &lt;head&gt;
          &lt;title&gt;Murat Ödev Sayfası&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Murat Ödev Sayfası&lt;/h1&gt;
          &lt;h2&gt;Giriş Durumu: Giriş yapıldı&lt;h2&gt;&lt;a href=&quot;/logout&quot;&gt;Çıkış yap&lt;/a&gt;
          &lt;a href=&quot;/profil&quot;&gt;Profil sayfası&lt;/a&gt;
          &lt;a href=&quot;/video&quot;&gt;Video test&lt;/a&gt;
      &lt;/body&gt;
      ` : `
      &lt;!DOCTYPE html&gt;
      &lt;head&gt;
          &lt;title&gt;Murat Ödev Sayfası&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Murat Ödev Sayfası&lt;/h1&gt;
          &lt;h2&gt;Giriş Durumu: Giriş yapılmadı&lt;h2&gt;&lt;a href=&quot;/login&quot;&gt;Giriş yap&lt;/a&gt;
      &lt;/body&gt;
      `)
  })
  
  
  app.get('/video', requiresAuth(),(req, res) =&gt; {
      const range = req.headers.range;
    if (!range) {
      res.status(400).send(&quot;Requires Range header&quot;);
    }
  
    // get video stats (about 61MB)
    const videoPath = &quot;video.mp4&quot;;
    const videoSize = fs.statSync(&quot;video.mp4&quot;).size;
  
    // Parse Range
    // Example: &quot;bytes=32324-&quot;
    const CHUNK_SIZE = 10 ** 6; // 1MB
    const start = Number(range.replace(&quot;/\D/g&quot;, &quot;&quot;));
    const end = Math.min(start + CHUNK_SIZE, videoSize - 1);
  
    // Create headers
    const contentLength = end - start + 1;
    const headers = {
      &quot;Content-Range&quot;: `bytes ${start}-${end}/${videoSize}`,
      &quot;Accept-Ranges&quot;: &quot;bytes&quot;,
      &quot;Content-Length&quot;: contentLength,
      &quot;Content-Type&quot;: &quot;video/mp4&quot;,
    };
  
    // HTTP Status 206 for Partial Content
    res.writeHead(206, headers);
  
    // create video read stream for this particular chunk
    const videoStream = fs.createReadStream(videoPath, { start, end });
  
    // Stream the video chunk to the client
    videoStream.pipe(res);
  })
  
  const port = process.env.PORT || 3000;
  app.listen(port, () =&gt; {
      console.log(`Listening on port ${port}`);
  })
  </code></pre>
  <p>and the error is:</p>
  <pre><code>TypeError: Cannot read property 'replace' of undefined
  </code></pre>
  <p>I hope theres someone that can help me</p>