CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.
MIT License
2.11k stars 174 forks source link

Carter seems to ignore UsePathBase #247

Closed phillip-haydon closed 2 years ago

phillip-haydon commented 4 years ago
app.UseRouting();
app.UsePathBase("/api");
app.UseEndpoints(builder => builder.MapCarter());

When using Carter with a base path, it seems to ignore it. Do I have to go define this as a base module?

jchannon commented 4 years ago

Correct.

Didn’t know if that middleware. Could add some code to check if it’s set but a base module will work for now

On Mon, 25 May 2020 at 06:38, Phillip Haydon notifications@github.com wrote:

app.UseRouting(); app.UsePathBase("/api"); app.UseEndpoints(builder => builder.MapCarter());

When using Carter with a base path, it seems to ignore it. Do I have to go define this as a base module?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CarterCommunity/Carter/issues/247, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZVJROCPKNFCP32X2Z3SLRTH753ANCNFSM4NJHPLHA .

phillip-haydon commented 4 years ago

I believe it's built in. Doesn't need any special dependency.

It's strange tho, as it requires the route to begin with / but routes in ASP.NET cannot start with /

jbogard commented 2 years ago

@jchannon Looks like this still ignores UsePathBase which we use for reverse proxies, do we need to create a base module to set a base path?

jchannon commented 2 years ago

If this is on .NET6 then it I would have thought it would behave properly and use the base path however I've not checked how the minimal routing works with a base path.

If pre .NET6 then a base module should work

jbogard commented 2 years ago

Yah it's .NET 6. I'll poke around

jchannon commented 2 years ago

My guess with minimal apis is that you'll have to be explicit in the route definition which kinda sucks

On Mon, 10 Jan 2022 at 15:02, Jimmy Bogard @.***> wrote:

Yah it's .NET 6. I'll poke around

— Reply to this email directly, view it on GitHub https://github.com/CarterCommunity/Carter/issues/247#issuecomment-1008957904, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZVJWSIY32KKVZ4NRNABTUVLYJHANCNFSM4NJHPLHA . You are receiving this because you were mentioned.Message ID: @.***>

jbogard commented 2 years ago

It's not Carter, it's a thing with minimal routing:

https://github.com/dotnet/aspnetcore/issues/38448

Adding the call to UseRouting fixed for me:

app.UsePathBase("/api");
app.UseRouting();
app.MapCarter();