fix production login issue
Build & Push / Pipeline Tests (push) Successful in 1m53s
Test / Type Check (all packages) (push) Successful in 56s
Build & Push / Build & Push Docker Image (push) Successful in 4m19s
Test / API Unit Tests (push) Successful in 1m17s
Test / Homepage Unit Tests (push) Successful in 49s
Test / Carplace Unit Tests (push) Successful in 46s
Test / Admin Unit Tests (push) Successful in 42s
Test / Dashboard Unit Tests (push) Successful in 44s
Test / API Integration Tests (push) Successful in 1m7s
Build & Push / Pipeline Tests (push) Successful in 1m53s
Test / Type Check (all packages) (push) Successful in 56s
Build & Push / Build & Push Docker Image (push) Successful in 4m19s
Test / API Unit Tests (push) Successful in 1m17s
Test / Homepage Unit Tests (push) Successful in 49s
Test / Carplace Unit Tests (push) Successful in 46s
Test / Admin Unit Tests (push) Successful in 42s
Test / Dashboard Unit Tests (push) Successful in 44s
Test / API Integration Tests (push) Successful in 1m7s
This commit is contained in:
@@ -167,6 +167,34 @@ describe('dashboard apiFetch', () => {
|
||||
expect(api.resolveApiOrigin()).toBe('http://localhost:4000')
|
||||
})
|
||||
|
||||
it('routes proxied realtime connections through the dashboard socket path', async () => {
|
||||
installBrowser()
|
||||
setBrowserHostname('rentaldrivego.ma')
|
||||
;(globalThis.window as any).location.origin = 'https://rentaldrivego.ma'
|
||||
process.env.NEXT_PUBLIC_API_URL = 'https://api.rentaldrivego.ma/api/v1'
|
||||
|
||||
const api = await import('./api')
|
||||
|
||||
expect(api.resolveRealtimeSocketTarget()).toEqual({
|
||||
origin: 'https://rentaldrivego.ma',
|
||||
path: '/dashboard/socket.io',
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps direct realtime connections on the default socket path for same-host API bases', async () => {
|
||||
installBrowser()
|
||||
setBrowserHostname('rentaldrivego.ma')
|
||||
;(globalThis.window as any).location.origin = 'https://rentaldrivego.ma'
|
||||
process.env.NEXT_PUBLIC_API_URL = 'https://rentaldrivego.ma/api/v1'
|
||||
|
||||
const api = await import('./api')
|
||||
|
||||
expect(api.resolveRealtimeSocketTarget()).toEqual({
|
||||
origin: 'https://rentaldrivego.ma',
|
||||
path: '/socket.io',
|
||||
})
|
||||
})
|
||||
|
||||
it('does not force JSON content type for FormData payloads', async () => {
|
||||
installBrowser()
|
||||
const fetchMock = vi.fn(async () => ({ ok: true, json: async () => ({ data: { uploaded: true } }) }))
|
||||
|
||||
@@ -44,6 +44,20 @@ 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
|
||||
|
||||
return {
|
||||
origin,
|
||||
path: isDashboardProxy ? '/dashboard/socket.io' : '/socket.io',
|
||||
}
|
||||
}
|
||||
|
||||
export const API_BASE = resolveApiBase()
|
||||
|
||||
export const EMPLOYEE_PROFILE_KEY = 'employee_profile'
|
||||
|
||||
Reference in New Issue
Block a user