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

AddPathRemovePrefix does not work #2429

Closed
239573049 opened this issue Mar 6, 2024 · 5 comments
Closed

AddPathRemovePrefix does not work #2429

239573049 opened this issue Mar 6, 2024 · 5 comments
Labels
needs more info Type: Bug Something isn't working

Comments

@239573049
Copy link

239573049 commented Mar 6, 2024

Describe the bug

When using the default

app.MapForwarder("/sample/anything/{id}", "https://httpbin.org", b => b.AddPathRemovePrefix("/sample"));

Is valid, but currently in use

app.MapForwarder("/sample/{**catch-all}", "https://httpbin.org", b => b.AddPathRemovePrefix("/sample"));

I need to block all routes forwarded to the service under '/sample/' and forward them without '/sample'

To Reproduce

Further technical details

  • Include the version of the packages you are using
  • The platform (Windows)
@239573049 239573049 added the Type: Bug Something isn't working label Mar 6, 2024
@MihaZupan
Copy link
Member

Can you clarify what you mean by "does not work"? What URLs were you testing with / do you have other routes registered?

/sample/anything/{id} and /sample/{**catch-all}" would both match a request to /sample/anything/foo.
Note that routing will prefer the most specific match, so if you had both of the above routes, /sample/anything/{id} would be picked.

@239573049
Copy link
Author

I need to remove the prefix /sample/anything when using the proxy, but the prefix cannot be removed when using /sample/{**catch-all}.

@MihaZupan
Copy link
Member

It can, AddPathRemovePrefix doesn't care about the route template you specified.

Are you sure your requests are matching the correct route?
I would suggest bumping the log levels to see what is happening.

"LogLevel": {
  "Default": "Debug",
  "Microsoft": "Debug",
  "Microsoft.Hosting.Lifetime": "Information"
}

Otherwise can you provide a full repro project that we can look at?

@239573049
Copy link
Author

I tried the demo and it seemed to work

@239573049
Copy link
Author

I tried the demo and it seemed to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants