fix: normalize homepage API URL and enforce expired trial access
Build & Deploy / Build & Push Docker Image (push) Successful in 2m54s
Test / Type Check (all packages) (push) Successful in 52s
Build & Deploy / Deploy to VPS (push) Successful in 3s
Test / API Unit Tests (push) Failing after 1m9s
Test / Homepage Unit Tests (push) Successful in 45s
Test / Storefront Unit Tests (push) Successful in 41s
Test / Admin Unit Tests (push) Successful in 43s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Successful in 1m0s

This commit is contained in:
root
2026-07-02 02:45:08 -04:00
parent 75a1d39050
commit 13b54f07de
2 changed files with 25 additions and 2 deletions
+8 -2
View File
@@ -1,6 +1,12 @@
export const API_BASE = export function normalizeApiBase(value: string): string {
const base = value.replace(/\/+$/, '')
return /\/api\/v1$/.test(base) ? base : `${base}/api/v1`
}
export const API_BASE = normalizeApiBase(
typeof window === 'undefined' typeof window === 'undefined'
? (process.env.API_INTERNAL_URL || 'http://localhost:4000/api/v1') ? (process.env.API_INTERNAL_URL || 'http://localhost:4000/api/v1')
: (process.env.NEXT_PUBLIC_API_URL || '/api/v1') : (process.env.NEXT_PUBLIC_API_URL || '/api/v1'),
)
export const EMPLOYEE_PROFILE_KEY = 'employee_profile' export const EMPLOYEE_PROFILE_KEY = 'employee_profile'
+17
View File
@@ -0,0 +1,17 @@
import { describe, expect, it } from 'vitest';
import { normalizeApiBase } from '@/lib/api';
describe('homepage API base URL', () => {
it('keeps API URLs that already include the version prefix', () => {
expect(normalizeApiBase('https://api.rentaldrivego.ma/api/v1')).toBe('https://api.rentaldrivego.ma/api/v1');
});
it('adds the version prefix when production env only contains the API host', () => {
expect(normalizeApiBase('https://api.rentaldrivego.ma')).toBe('https://api.rentaldrivego.ma/api/v1');
});
it('normalizes trailing slashes before appending the version prefix', () => {
expect(normalizeApiBase('https://api.rentaldrivego.ma/')).toBe('https://api.rentaldrivego.ma/api/v1');
});
});