add subscription upgrade plan
Build & Push / Pipeline Tests (push) Failing after 2m0s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 53s
Test / API Unit Tests (push) Successful in 1m8s
Test / Homepage Unit Tests (push) Successful in 48s
Test / Carplace Unit Tests (push) Successful in 42s
Test / Admin Unit Tests (push) Successful in 41s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Failing after 1m7s
Build & Push / Pipeline Tests (push) Failing after 2m0s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 53s
Test / API Unit Tests (push) Successful in 1m8s
Test / Homepage Unit Tests (push) Successful in 48s
Test / Carplace Unit Tests (push) Successful in 42s
Test / Admin Unit Tests (push) Successful in 41s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Failing after 1m7s
This commit is contained in:
@@ -184,12 +184,12 @@ describe('dashboard apiFetch', () => {
|
||||
credentials: 'include',
|
||||
}))
|
||||
expect(resolveRealtimeSocketTarget()).toEqual({
|
||||
origin: 'http://localhost:3000',
|
||||
path: '/dashboard/socket.io',
|
||||
origin: 'http://localhost:4000',
|
||||
path: '/socket.io',
|
||||
})
|
||||
})
|
||||
|
||||
it('routes proxied realtime connections through the dashboard socket path', async () => {
|
||||
it('routes realtime connections to the configured API origin instead of the dashboard proxy path', async () => {
|
||||
installBrowser()
|
||||
setBrowserHostname('rentaldrivego.ma')
|
||||
;(globalThis.window as any).location.origin = 'https://rentaldrivego.ma'
|
||||
@@ -198,8 +198,8 @@ describe('dashboard apiFetch', () => {
|
||||
const api = await import('./api')
|
||||
|
||||
expect(api.resolveRealtimeSocketTarget()).toEqual({
|
||||
origin: 'https://rentaldrivego.ma',
|
||||
path: '/dashboard/socket.io',
|
||||
origin: 'https://api.rentaldrivego.ma',
|
||||
path: '/socket.io',
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -55,14 +55,29 @@ export function resolveApiOrigin(): string | null {
|
||||
export function resolveRealtimeSocketTarget(): { origin: string; path: string } | null {
|
||||
if (typeof window === 'undefined') return null
|
||||
|
||||
const apiBase = resolveApiBase()
|
||||
const isDashboardProxy = apiBase === DASHBOARD_PROXY_API_BASE || apiBase.startsWith(`${DASHBOARD_PROXY_API_BASE}/`)
|
||||
const origin = isDashboardProxy ? window.location.origin : resolveApiOrigin()
|
||||
if (!origin) return null
|
||||
const configuredApiBase = process.env.NEXT_PUBLIC_API_URL
|
||||
if (configuredApiBase && !configuredApiBase.startsWith('/')) {
|
||||
try {
|
||||
return {
|
||||
origin: new URL(normalizeApiBase(configuredApiBase)).origin,
|
||||
path: '/socket.io',
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const currentHostname = window.location?.hostname
|
||||
if (currentHostname && isLocalBrowserHost(currentHostname)) {
|
||||
return {
|
||||
origin: 'http://localhost:4000',
|
||||
path: '/socket.io',
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
origin,
|
||||
path: isDashboardProxy ? '/dashboard/socket.io' : '/socket.io',
|
||||
origin: resolveApiOrigin() ?? window.location.origin,
|
||||
path: '/socket.io',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user