Open Closed

No "Abp-Tenant-Resolve-Error" header in HttpErrorResponse #4896


User avatar
0
dkaczor created
  • ABP Framework version: v7.1.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

I am implementing a tenant self-registration behaviour with subscriptions, payments etc. I want to display an error page with contact informations when tenant subscription ends and it is no longer active. By default there is no such page in angular - only Error 404 page is displayed. On server side a basic page with error details is displayed. I am trying to implement custom http error handler in angular. The problem is that I cannot check if the error is caused by tenant being inactive. I found in your source code that "Abp-Tenant-Resolve-Error" header should be added to the response from server. Unfortunately in error handler the error response does not have it. Is this a configuration matter? How can I find out if the error is tenancy-related?

EDIT: I didn't mention it - I am using domain tenant resolver.


6 Answer(s)
  • User Avatar
    0
    mahmut.gundogdu created

    The "Abp-Tenant-Resolver-Error" is thrown by the backend when the tenant is removed. Then the Auth server or Angular( When the user selects Password Owner Flow) catch the error, and if the header exits, it executed the fn. you can check the code.

    https://github.com/abpframework/abp/blob/74601db85efb094e17d8ccf0651107458374d452/npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts#L150

    Deleted Tenant cause issuer/errors. that related with cleaning issue. So we need a additional header for this. It is missing. I have talked my teammates.When the answer arrived, I will send more infromation.

  • User Avatar
    0
    mahmut.gundogdu created

    I have asked. ABP return the a header when the tenant passive. Here you can see in the screen. that is handled in ABP. I would copy this file in Myproject and Set a name like MyErrorHandler. then I would override the functionalty.

    https://github.com/abpframework/abp/blob/74601db85efb094e17d8ccf0651107458374d452/npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts#L150

  • User Avatar
    0
    dkaczor created

    I know how it should work and what that header means. I wrote the ticket because it does not work that way.

    I created a new project, v7.1.1. I overrode the error handler as you described. I added new active tenant, logged in on another browser, deactivated the tenant and refreshed the second browser. Here are the results:

    The "Abp-Tenant-Resolve-Error" is visible in devtools but I cannot access it from angular code. It is null, it does not exist.

  • User Avatar
    0
    mahmut.gundogdu created

    Did you add AbpTenantResolverError on Cors ? I saw access-control-expose-headers does not include that key.

    Here it must be like that https://github.com/abpframework/abp/blob/rel-7.1/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The MultiTenancyMiddlewareErrorPageBuilder will respond to a 404 html page by default. But you can custom it.

    eg: response a JSON result.

    https://github.com/abpframework/abp/blob/e55c6f97174b10d982b73c5ae9c01b2edbe194df/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs#L31

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#abpmultitenancyoptions-handle-inactive-and-non-existent-tenants

  • User Avatar
    0
    dkaczor created

    After adding my custom CorsPolicyBuilderExtension I'm finally able to read the header in angular. I think it should be in the framework by default. I see it was just added in v7.2.0 which is not released yet. It's missing in previous stable verions. Therefore I consider it a bug and I would appreciate refunding my ticket. Thanks.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15