Open Closed

Subdomain Issue #6386


User avatar
0
jaykishan created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index 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:

  • ABP Framework version: vX.X.X
  • UI Type: MVC
  • Database System: EF Core (MySQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Example:

For Host Domain

Authserver: accounts.test.com Web Server: test.com Api Server: api.test.com

When unauthorized user is making a webcall it calls api.test.com

For Tenant Domain

Authserver: subdomain.accounts.test.com Web Server: subdomain.test.com Tenant Api Server: subdomain.api.test.com

Issue: When unauthorized user is making a webcall from subdomain like subdomain.test.com it calls api.test.com Expected: When unauthorized user is making a webcall from subdomain like subdomain.test.com it should call subdomain.api.test.com

In angular it should not be an issue as it is specificing in the config file {0}.api.test.com

But in MVC it is not working

"RemoteServices": { "Default": { "BaseUrl": "https://{{tenantName}}.api.test.com/" (with or without tenantName interpolation it is not working) } }

I have verified below configuration are correct:

Also, please note api.test.com it works as it is host (Correct Behaviour) subdomain.api.test.com it works as it was created as tenant (Correct Behaviour) wrong.api.test.com it does not work as it was never created as tenant (Correct Behaviour as tenant does not exist with name "wrong")

Please help with temporary workaround or is it a bug?


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This may be a problem

    May I ask which version are you using?

  • User Avatar
    0
    jaykishan created

    I am having issue from version 7.0 to 7.4 major version, currently it is the same in 7.4.4

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Will this work for you(Add to MVC project)?

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IRemoteServiceConfigurationProvider))]
    public class MyRemoteServiceConfigurationProvider : IRemoteServiceConfigurationProvider
    {
        protected AbpRemoteServiceOptions Options { get; }
        protected IAppUrlProvider AppUrlProvider { get; }
    
        public MyRemoteServiceConfigurationProvider(
            IOptionsMonitor<AbpRemoteServiceOptions> options, 
            IAppUrlProvider appUrlProvider)
        {
            AppUrlProvider = appUrlProvider;
            Options = options.CurrentValue;
        }
    
        public async Task<RemoteServiceConfiguration> GetConfigurationOrDefaultAsync(string name)
        {
            var configuration = Options.RemoteServices.GetConfigurationOrDefault(name);
            configuration.BaseUrl = await AppUrlProvider.NormalizeUrlAsync(configuration.BaseUrl);
            return configuration;
        }
    
        public async Task<RemoteServiceConfiguration?> GetConfigurationOrDefaultOrNullAsync(string name)
        {
            var configuration = Options.RemoteServices.GetConfigurationOrDefaultOrNull(name);
            if (configuration != null)
            {
                configuration.BaseUrl = await AppUrlProvider.NormalizeUrlAsync(configuration.BaseUrl);
            }
            
            return configuration;
        }
    }
    
  • User Avatar
    0
    jaykishan created

    Thank you liangshiwei for pointing me in right direction. I know it was a breaking change if it was suppose to be going live.

    Below is the code that worked for me.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    We will fix it in the next patch version, your ticket has been refunded.

  • User Avatar
    0
    jaykishan created

    Thank you for refund and closing the ticket.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11