Fix double /api/ prefix in API endpoint calls

When VITE_API_URL=/api, axios baseURL is already set to /api. However, all endpoint calls included the /api/ prefix, creating double paths like /api/api/auth/login/.

Removed /api/ prefix from 81 API endpoint calls across 22 files:
- src/api/auth.ts - Fixed login, logout, me, refresh, hijack endpoints
- src/api/client.ts - Fixed token refresh endpoint
- src/api/profile.ts - Fixed all profile, email, password, MFA, sessions endpoints
- src/hooks/*.ts - Fixed all remaining API calls (users, appointments, resources, etc)
- src/pages/*.tsx - Fixed signup and email verification endpoints

This ensures API requests use the correct path: /api/auth/login/ instead of /api/api/auth/login/

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
poduck
2025-11-30 15:27:57 -05:00
parent f1d4dac9d2
commit 4cd6610f2a
53 changed files with 476 additions and 687 deletions

View File

@@ -2,19 +2,19 @@
* Cookie utilities for cross-subdomain token storage
*/
import { getCookieDomain } from './domain';
/**
* Set a cookie with domain attribute for cross-subdomain access
* Uses .lvh.me for local development (lvh.me supports subdomains, unlike localhost)
* Dynamically determines the correct domain based on current environment
*/
export const setCookie = (name: string, value: string, days: number = 7) => {
const expires = new Date();
expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
// Set cookie with domain=.lvh.me for local dev, accessible across all subdomains
// For localhost, don't set domain attribute - let it default to current host
const hostname = window.location.hostname;
const isLocalhost = hostname === 'localhost' || hostname === '127.0.0.1';
const domainAttr = hostname.includes('lvh.me') ? `;domain=.lvh.me` : isLocalhost ? '' : `;domain=${hostname}`;
// Get cookie domain dynamically (.lvh.me in dev, .smoothschedule.com in prod, localhost for localhost)
const cookieDomain = getCookieDomain();
const domainAttr = cookieDomain === 'localhost' ? '' : `;domain=${cookieDomain}`;
document.cookie = `${name}=${value};expires=${expires.toUTCString()}${domainAttr};path=/;SameSite=Lax`;
};
@@ -39,8 +39,7 @@ export const getCookie = (name: string): string | null => {
* Delete a cookie
*/
export const deleteCookie = (name: string) => {
const hostname = window.location.hostname;
const isLocalhost = hostname === 'localhost' || hostname === '127.0.0.1';
const domainAttr = hostname.includes('lvh.me') ? `;domain=.lvh.me` : isLocalhost ? '' : `;domain=${hostname}`;
const cookieDomain = getCookieDomain();
const domainAttr = cookieDomain === 'localhost' ? '' : `;domain=${cookieDomain}`;
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC${domainAttr};path=/;`;
};