Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query parameters are missing after a rewrite #17

Closed
ubwhole opened this issue Feb 7, 2018 · 1 comment
Closed

Query parameters are missing after a rewrite #17

ubwhole opened this issue Feb 7, 2018 · 1 comment

Comments

@ubwhole
Copy link

ubwhole commented Feb 7, 2018

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
Copy link
Author

ubwhole commented Feb 8, 2018

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

@ubwhole ubwhole closed this as completed Feb 8, 2018
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

No branches or pull requests

1 participant