Skip to content

serve-static not working with Restana 5.0.0 #118

@tripodsgames

Description

@tripodsgames

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);
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions