Hello,
We're using the ABP microservice template for a blazor web app that is deployed on AKS.
Our auth server is currently deployed and reachable on a /auth
path.
When trying to Submit the personal info or change password on the "My account" page of the auth server we get a 404. In the network tab we see that our /auth base path is not in the url used to do the request even though we have properly set the app.UsePathBase("/auth")
in the auth server module.
Is there anything other than the base path that needs to be set in order to get the auth/account actions working under a base path on the auth server?
Thanks
6 Answer(s)
-
0
-
0
Hey, thanks for the response.
Unless i'm mistaken, the auth server requests targeting the /api/account/my-profile within the Account/Manage page does not go through the web gateway.
Locally, when running everything as default and without any custom base path for my auth server, I do see all /api/account/my-profile requests reaching the auth server directly without going through the web gateway. I can repro the same behavior when starting from a new microservice template.
Repro steps:
- Create a new microservice solution with a Blazor web app
- Go on the /Account/Manage page hosted on the auth server
- Change password and submit
- Notice that the /api/account requests are directly sent to the auth server and not the web gateway
-
0
Hello,
Yes, I can reproduce what you said last time. There is nothing wrong here, it works as expected. However, I think you are using UsePathBase incorrectly.
If you use
UsePathBase(โ/authโ)
, the requests should be/auth/api/account/...
not/api/account/...
. So you also need to change the endpoint of the controllers.I created a class like below to change the prefix of all controllers:
public class GlobalRouteReplaceConvention : IApplicationModelConvention { private readonly string _oldPrefix; private readonly string _newPrefix; public GlobalRouteReplaceConvention(string oldPrefix, string newPrefix) { _oldPrefix = oldPrefix.Trim('/'); _newPrefix = newPrefix.Trim('/'); } public void Apply(ApplicationModel application) { foreach (var controller in application.Controllers) { foreach (var selector in controller.Selectors.Where(s => s.AttributeRouteModel != null)) { var template = selector.AttributeRouteModel.Template; if (template.StartsWith(_oldPrefix)) { selector.AttributeRouteModel.Template = _newPrefix + template.Substring(_oldPrefix.Length); } else { selector.AttributeRouteModel = AttributeRouteModel.CombineAttributeRouteModel( new AttributeRouteModel(new Microsoft.AspNetCore.Mvc.RouteAttribute(_newPrefix)), selector.AttributeRouteModel ); } } } } }
Then I called it in the ConfigureServices method of the module as follows:
context.Services.AddControllers(options => { options.Conventions.Insert(0, new GlobalRouteReplaceConvention("api", "auth/api")); });
Result:
Then I added
app.UsePathBase(โ/authโ);
middleware as you did.Then in my case everything works properly.
If you think I misunderstood your question, I would be grateful if you could direct me again ๐
-
0
context.Services.AddControllers(options => { options.Conventions.Insert(0, new GlobalRouteReplaceConvention("api", "auth/api")); });
I don't think replacing the api controller convention will work in my case.
It's the actual url used to make the change-password request that is not accounting for the path base. I did try to change the conventions based on your response and the URL used internally is still the same as before.
Where is that URL taken from and how can I override it to include my base path?
-
0
-
0
Hi Shodgson ๐,
Apologies for the delay in responding โ we were off yesterday due to International Workers' Day. I'm really glad to hear that you were able to resolve the issue!
Closing the issue now. Feel free to create a new one if you have any further questions.