arbret/frontend/e2e/helpers/backend-url.ts
2025-12-26 19:21:34 +01:00

22 lines
711 B
TypeScript

/**
* Helper to determine which backend URL to use based on Playwright worker index.
* Each worker gets its own backend instance and database.
*/
/**
* Get the backend URL for the current Playwright worker.
* Uses NEXT_PUBLIC_API_URL which is set in setup.ts based on worker index.
* Falls back to environment variable or default port 8001.
*/
export function getBackendUrl(): string {
// NEXT_PUBLIC_API_URL is set in setup.ts based on worker index
return process.env.NEXT_PUBLIC_API_URL || "http://localhost:8001";
}
/**
* Get the API URL for the current worker.
* This is the same as getBackendUrl but with a clearer name.
*/
export function getApiUrl(): string {
return getBackendUrl();
}