title: Serve svg file using express
body: <p>I would like to know how to serve an svg file using Express.</p>
  
  <p>Here is what I have attempted so far:</p>
  
  <p><strong>svg file</strong></p>
  
  <pre><code>&lt;svg width="400" height="180"&gt;
    &lt;g&gt;
      &lt;rect x="50" y="20" rx="20" ry="20" width="150" height="150"
        style="fill:red;stroke: black;stroke-width:5;opacity:0.5"&gt;&lt;/rect&gt;
    &lt;/g&gt;
  &lt;/svg&gt;
  </code></pre>
  
  <p><strong>route file</strong></p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  router.get('/myRoute', function (req, res, next) {
    res.setHeader('Content-Type', 'image/svg+xml');
    res.sendFile('../views/status.svg');
  });
  
  module.exports = router;
  </code></pre>
  
  <p>But when I point my browser to that route, I get the following error:</p>
  
  <pre><code>This page contains the following errors:
  
  error on line 1 at column 103: Opening and ending tag mismatch: link line 0 and head
  Below is a rendering of the page up to the first error.
  </code></pre>
  
  <p>I don't know why this is not working and not sure where "line 1 at column 103" is pointing to. There is no such line and column in my codebase.</p>
  
  <p>Any suggestions?</p>