diff --git a/packages/core/src/domain/configuration.spec.ts b/packages/core/src/domain/configuration.spec.ts index 216c6d9a03..3f2983431a 100644 --- a/packages/core/src/domain/configuration.spec.ts +++ b/packages/core/src/domain/configuration.spec.ts @@ -132,6 +132,16 @@ describe('configuration', () => { expect(configuration.isIntakeUrl('https://trace.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true) }) + it('should handle sites with subdomains', () => { + const configuration = buildConfiguration( + { clientToken, site: 'us3.datadoghq.com', useAlternateIntakeDomains: true }, + usEnv + ) + expect(configuration.isIntakeUrl('https://rum.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true) + expect(configuration.isIntakeUrl('https://logs.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true) + expect(configuration.isIntakeUrl('https://trace.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true) + }) + it('should detect proxy intake request', () => { let configuration = buildConfiguration({ clientToken, proxyHost: 'www.proxy.com' }, usEnv) expect(configuration.isIntakeUrl('https://www.proxy.com/v1/input/xxx')).toBe(true) diff --git a/packages/core/src/domain/configuration.ts b/packages/core/src/domain/configuration.ts index f1b41c51fc..8fa7bead08 100644 --- a/packages/core/src/domain/configuration.ts +++ b/packages/core/src/domain/configuration.ts @@ -250,7 +250,9 @@ function getEndpoint( function getHost(intakeType: IntakeType, endpointType: EndpointType, site: string) { const middleDomain = INTAKE_MIDDLE_DOMAINS[intakeType] const endpoint = ENDPOINTS[intakeType][endpointType] - return `${endpoint}${middleDomain}${site}` + const domainParts = site.split('.') + const ext = domainParts.pop() + return `${endpoint}${middleDomain}${domainParts.join('-')}.${ext}` } function getIntakeUrls(intakeType: IntakeType, conf: TransportConfiguration, withReplica: boolean) {