Skip to content

Conversation

yusukebe
Copy link
Member

@yusukebe yusukebe commented Apr 8, 2023

This PR enables rewriting a request path for Serve Static middleware.

If you want to serve files in ./.foojs with the request path /__foo/*, you can write:

 app.use(
  '/__foo/*',
  serveStatic({
    root: './.foojs/',
    rewriteRequestPath: (path: string) => path.replace(/^\/__foo/, ''),
  })
)

Fix #29

@yusukebe yusukebe merged commit 14a63dd into main Apr 8, 2023
@yusukebe yusukebe deleted the feat/rewrite-request-path branch April 8, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

serveStatic need optional parameter that allows to edit the route to file path
1 participant