import React, { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import './index.css' import App from './App.jsx' // Split hosting: when VITE_API_URL is set (e.g. https://api.mytechtrain.com), calls to /api/* // go to that origin and carry the refresh cookie. Unset in dev, where the Vite proxy handles /api. const API_URL = (import.meta.env.VITE_API_URL || '').replace(/\/$/, ''); if (API_URL) { const nativeFetch = window.fetch.bind(window); window.fetch = (input, init = {}) => typeof input === 'string' && input.startsWith('/api/') ? nativeFetch(API_URL + input, { credentials: 'include', ...init }) : nativeFetch(input, init); } class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error) { return { hasError: true, error }; } componentDidCatch(error, errorInfo) { console.error("Uncaught error:", error, errorInfo); } render() { if (this.state.hasError) { return (
{this.state.error.toString()}