24 lines
1010 B
JavaScript
24 lines
1010 B
JavaScript
// Centralizes base URLs so auth calls and data (opr) calls never get mixed up.
|
|
//
|
|
// authUrl('/auth/me') -> `${VITE_AUTH_SERVICE_URL}/auth/me`
|
|
// oprUrl('/products') -> `${VITE_OPR_API_URL}/products`
|
|
//
|
|
// In dev these resolve to relative paths (/auth-service, /opr-rest-api) that the
|
|
// Vite proxy forwards to the backend. In prod they should point at your gateway.
|
|
|
|
const AUTH_BASE = import.meta.env.VITE_AUTH_SERVICE_URL ?? ''
|
|
const CRM_BASE = import.meta.env.VITE_CRM_API_URL ?? ''
|
|
const OPR_BASE = import.meta.env.VITE_OPR_API_URL ?? ''
|
|
|
|
if (import.meta.env.DEV && !CRM_BASE) {
|
|
console.warn('[endpoints] VITE_CRM_API_URL is not set — crm/data calls have no base URL.')
|
|
}
|
|
|
|
if (import.meta.env.DEV && !OPR_BASE) {
|
|
console.warn('[endpoints] VITE_OPR_API_URL is not set — opr/data calls have no base URL.')
|
|
}
|
|
|
|
export const authUrl = (path = '') => `${AUTH_BASE}${path}`
|
|
export const crmUrl = (path = '') => `${CRM_BASE}${path}`
|
|
export const oprUrl = (path = '') => `${OPR_BASE}${path}`
|