Query parameters are missing after a rewrite
Closed this issue · 1 comments
ubwhole commented
I am using koa-rewrite ver 3.0.0. I specified the following in my app:
app.use(rewrite(/^\/p\/didit/, '/p/customers/section_id/didits'));
After the rewrite is executed, all of the query parameters are gone. I traced it down to the following line in index.js of koa-rewrite module:
ctx.url = dst.replace(/\$(\d+)|(?::(\w+))/g, (_, n, name) => {
if (name) return m[map[name].index + 1];
return m[n];
});
I am not sure why setting the url would cause the query parameters to be gone.
ubwhole commented
I updated my pattern to include the rest of the URL, which now the ctx.query is populated.
app.use(rewrite(/^\/p\/didit(.+)/, '/p/customers/section_id/didits$1'));