title: Node Fastify - serve images located in upload folder
body: <p>Make <strong>files/images</strong> available to be access, when we navigate to</p>
  <p><code>localhost:8000/properties/files/[image name]</code></p>
  <p><code>localhost:8000/properties/files/1635843023660-profile.jpg</code></p>
  <p><strong>File Structure</strong></p>
  <pre><code>node_modules
  src/
  uploads/
      1635843023660-profile.jpg
      1635843023668-home.jpg
  ...
  .env
  package.json
  </code></pre>
  <p><strong>index.js</strong></p>
  <pre><code>import Fastify from &quot;fastify&quot;;
  import FastifyStatic from &quot;fastify-static&quot;;
  import path from &quot;path&quot;;
  import { propertiesRoutes } from &quot;./routes/properties.js&quot;;
  ...
  export const fastify = await Fastify({ logger: process.env.LOGGER || true });
  
  const __dirname = path.resolve(path.dirname(&quot;&quot;));
  fastify.register(FastifyStatic, {
    root: path.join(__dirname, &quot;uploads&quot;),
  });
  fastify.register(propertiesRoutes, { prefix: &quot;/properties&quot; });
  ...
  </code></pre>
  <p><strong>routes/properties.js</strong></p>
  <pre><code>export const propertiesRoutes = function (fastify, opts, done) {
    ...
    fastify.get(&quot;/images/:name&quot;, (req, res) =&gt; {
      res.sendFile(process.cwd() + &quot;/uploads/&quot; + req.params.name);
    });
    done();
  };
  </code></pre>
  <p>as of right now I'm getting</p>
  <blockquote>
  <p>{&quot;message&quot;:&quot;Route GET:/properties/images/1635843023660-profile.jpg not
  found&quot;,&quot;error&quot;:&quot;Not Found&quot;,&quot;statusCode&quot;:404}</p>
  </blockquote>