restana icon indicating copy to clipboard operation
restana copied to clipboard

serve-static not working with Restana 5.0.0

Open tripodsgames opened this issue 7 months ago • 0 comments

Describe the bug
serve-static is not working with Restana 5.0.0.

To Reproduce
Steps to reproduce the behavior:

import restana from "restana";
import path from "path";

const api = restana()
.use('/static', serveStatic(path.join(proccess.cwd(), './static')));

await api.start(9000);

Expected behavior
Be able to access static files inside the static folder by url: http://localhost:9000/static/example.png

Desktop (please complete the following information):

  • OS: openSUSE Tumbleweed
  • Node Version: 22

Additional context
There is a simple fix:


restana()
    .use('/static', (req, res, next) => {
        req.url = req.url?.substring('/static'.length);
        return serveStatic(path.join(proccess.cwd(), './static'))(req, res, next);
    })

tripodsgames avatar Jun 12 '25 16:06 tripodsgames