diff --git a/src/core/index.js b/src/core/index.js index 9a0005569..fcd625406 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -337,6 +337,10 @@ function extractClientBaseUrlOption(opts, domain) { export function extractTenantBaseUrlOption(opts, domain) { if (opts.configurationBaseUrl && typeof opts.configurationBaseUrl === 'string') { + if (opts.overrides && opts.overrides.__tenant) { + // When using a custom domain and a configuration URL hosted in auth0's cdn + return urljoin(opts.configurationBaseUrl, 'tenants', 'v1', `${opts.overrides.__tenant}.js`); + } return urljoin(opts.configurationBaseUrl, 'info-v1.js'); } diff --git a/test/tenantinfo.test.js b/test/tenantinfo.test.js index 403e6bfa7..28df69554 100644 --- a/test/tenantinfo.test.js +++ b/test/tenantinfo.test.js @@ -6,6 +6,20 @@ import expect from 'expect.js'; import { extractTenantBaseUrlOption } from '../src/core/index'; describe('extractTenantBaseUrlOption', () => { + it('should return the configurationBaseUrl with tenant in path', () => { + var url = extractTenantBaseUrlOption( + { + configurationBaseUrl: 'https://test.com', + overrides: { + __tenant: 'lbalmaceda' + } + }, + 'lbalmaceda.auth0.com' + ); + + expect(url).to.be('https://test.com/tenants/v1/lbalmaceda.js'); + }); + it('should return the configurationBaseUrl', () => { var url = extractTenantBaseUrlOption( {