Check the docs before asking a question: https://abp.io/docs/latest Check the samples to see the basic tasks: https://abp.io/docs/latest/samples The exact solution to your question may have been answered before, and please first use the search on the homepage.
Provide us with the following info:
🧐 Hint: If you are using the ABP Studio, you can see all the information about your solution from the configuration window, which opens when you right-click on the solution and click on the Solution Configuration button.
- Exception message and full stack trace:
- Steps to reproduce the issue:
I am trying to rename host api from https://localhost:44320/ to https://localhost:44320/api/auth using appsettings.json, launchsettings.json. I am getting swagger error 404 because it cannot find the path. I am using sample project. Can you suggest a method ? I changed swagger endpoint and swagger base path and it does not work.

3 Answer(s)
-
0
The idea is not to use reverse proxy, can we rename host api server ?
-
0
- Solution You don’t need a reverse proxy to serve your HttpApi.Host under /api/auth, but you must consistently set a PathBase and align ALL generated URLs, route prefixes, and Swagger paths with it.
Goal: https://localhost:44320/api/auth should be the app’s base URL. Key rule: When you use app.UsePathBase("/api/auth"), every incoming request path and every generated URL must include /api/auth.
Apply these steps to your HttpApi.Host:
- Set PathBase early in the pipeline
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); app.UsePathBase("/api/auth"); app.UseRouting(); app.UseStaticFiles(); app.UseAbpStudioLink(); app.UseAbpSecurityHeaders(); app.UseCors(); app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseUnitOfWork(); app.UseDynamicClaims(); app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(options => { // Swagger endpoint MUST include the PathBase prefix options.SwaggerEndpoint("/api/auth/swagger/v1/swagger.json", "API"); // And make Swagger UI itself available under /api/auth/swagger options.RoutePrefix = "api/auth/swagger"; }); app.UseConfiguredEndpoints(); }- Make the app’s own “self” URL include the PathBase In your appsettings.json of HttpApi.Host:
{ "App": { "SelfUrl": "https://localhost:44320/api/auth" } }ABP uses App:SelfUrl for various generated links. If you keep it without the prefix, some URLs will be wrong.
Keep controller routes as-is You do NOT need to change [Route("api/...")] attributes or conventional controller prefixes. PathBase sits in front of the entire app, so /api/auth/api/values would be wrong. Correct request is /api/auth/api/values, which is “/api/auth” (PathBase) + “/api/values” (your controller route). Don’t double-prefix routes.
Swagger JSON endpoint path With PathBase, the JSON is served at /api/auth/swagger/v1/swagger.json. Ensure:
- app.UseSwagger() is after UsePathBase.
- SwaggerEndpoint uses the full path including /api/auth.
- If you view Swagger UI at https://localhost:44320/api/auth/swagger, the UI can fetch /api/auth/swagger/v1/swagger.json.
Anti-forgery and ABP Swagger UI script ABP’s Swagger integration injects abp.js to handle CSRF. With PathBase, the SetCsrfCookie endpoint will resolve correctly as long as App:SelfUrl and PathBase are consistent and the Swagger UI page is under the same PathBase.
If you also expose static assets under the same site Call app.UseStaticFiles() after UsePathBase so static files are served via /api/auth/… when requested from this host.
Common pitfalls that cause 404 in Swagger:
- PathBase set but SwaggerEndpoint missing the prefix. Correct: options.SwaggerEndpoint("/api/auth/swagger/v1/swagger.json", ...).
- Setting RoutePrefix to “swagger” while PathBase is “/api/auth”, then browsing https://localhost:44320/swagger (wrong). With RoutePrefix = "api/auth/swagger", browse https://localhost:44320/api/auth/swagger.
- Changing controller route prefixes to include “auth” while also using PathBase, which doubles the segment.
Optional (only if you must run the UI at root /swagger while API is under /api/auth):
- Keep PathBase("/api/auth").
- Set options.RoutePrefix = "swagger" and options.SwaggerEndpoint("/api/auth/swagger/v1/swagger.json", ...).
- You will browse Swagger at https://localhost:44320/swagger, but the JSON still resolves under /api/auth/… This is valid if you prefer Swagger at root.
- Sources
- ABP Swagger integration (validated):
- https://abp.io/docs/latest
- ABP Framework GitHub (for reference of Swagger integration and middleware ordering patterns) (validated):
- https://github.com/abpframework/abp
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0

