node-server icon indicating copy to clipboard operation
node-server copied to clipboard

Feature request: context for rewriteRequestPath function

Open vanodevium opened this issue 10 months ago • 2 comments

I have a very interesting case: I need to change the folder where the files are actually located, depending on the cookies that the user has.

So I really miss the context object in this function as the second argument.

Could you add it, please.

Example: something like

app.use(
  "/*",
  serveStatic({
    root: "./public/",
    rewriteRequestPath: (path, ctx) => path.replace('...', getCookie(ctx, 'concrete'))
  }),
);

vanodevium avatar Feb 24 '25 10:02 vanodevium

Hi @vanodevium

This is a good idea. Someone or I can work on it. Thank you.

yusukebe avatar Feb 26 '25 08:02 yusukebe

@yusukebe I could make this change myself, but I'm not good at typescript at all.

However, I really need this feature as soon as possible.

vanodevium avatar Feb 28 '25 15:02 vanodevium

@yusukebe Sorry to bother you. Any updates for this?

vanodevium avatar Jul 01 '25 12:07 vanodevium

@yusukebe Thank you!

vanodevium avatar Jul 02 '25 10:07 vanodevium

@vanodevium

I forgot it completely. Sorry! I've released the latest version, 1.15.0. Can you try it?

yusukebe avatar Jul 02 '25 10:07 yusukebe

@yusukebe Already in progress. I'll write feedback.

vanodevium avatar Jul 02 '25 10:07 vanodevium

@yusukebe Works like a charm. Thanx again!

vanodevium avatar Jul 02 '25 10:07 vanodevium