Open Closed

Forward __tenant as query string to Authentication Server #9140


User avatar
0
JimmyLiew created

Hi, I have implemented subdomain tenant resolver in angular frontend by adding {0} placeholder to determine current tenant.

Noticed that, when angular redirect to auth-server, __tenant custom header does not forward due to the redirect with 302 status code behavior. (Please correct me if I'm wrong.) https://stackoverflow.com/questions/46133557/why-is-my-header-not-being-set-on-redirect

Workaround Solution - Pass __tenant as query string instead of request header.

Question: As per abp documentation, abp backend already built-in QueryStringTenantResolveContributor to resolve the tenant by trying to find current tenant id from query string parameters. May i know how to implement QueryStringTenantResolveContributorin frontend so that "__tenant" will append as query string in URL and forwards to authentication server and trigger QueryStringTenantResolveContributor to resolve tenant seamlessly?

For example: Angular : https://tenant1.app.example.com AuthServer: https://auth-server.example.com?__tenant=tenant1

Thanks.


29 Answer(s)
  • User Avatar
    0
    sumeyye.kurtulus created
    Support Team Angular Expert

    Hello again,

    Apologies for the delayed response, and thank you for your patience and the detailed information you've provided.

    After revisiting your implementation, I can confirm that the issue stems from the OpenID Connect library appending an unnecessary query string (?&&) that isn't properly handled. Normally, Angular routing takes care of cleaning up such artifacts, but unfortunately, this particular case falls outside of its scope.

    As a temporary workaround until a permanent fix is released, I recommend the following approach:

    import { OAuthService } from 'angular-oauth2-oidc';
    
    export class AppComponent implements OnInit {
      protected oauthService = inject(OAuthService);
      protected windowService = inject(AbpWindowService);
    
      ngOnInit() {
        this.oauthService.events.subscribe(event => {
          if (event.type === 'token_received') {
            const rawQuery = window.location.search;
            if (rawQuery && !rawQuery.includes('=')) {
              this.windowService.reloadPage();
            }
          }
        });
      }
    }
    

    This solution listens for the token_received event and reloads the page when a malformed query string is detected, helping to mitigate the issue in both development and production environments.

    Let me know if you need further assistance.

  • User Avatar
    0
    JimmyLiew created

    Hi,

    The workaround solution is working. May I know in which version release the permanent fix will be included?

    Thanks.

  • User Avatar
    0
    sumeyye.kurtulus created
    Support Team Angular Expert

    Hello, I am delighted to hear that the workaround has solved your problem. The permanent fix will be available within the next patch release. You can follow this link regarding releases: https://github.com/abpframework/abp/releases

    Thank you for your cooperation.

  • User Avatar
    0
    JimmyLiew created

    Hi,

    Thank you for your support and the information provided!

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37