# Network Error Fix: "Failed to apply promotions"

## Problem

The frontend was showing "Network error: Failed to apply promotions" when trying to apply promotions in the POS system.

## Root Cause

The frontend services were configured to make direct requests to `https://sellzaki.local` which was causing network connectivity issues due to:

1. SSL certificate problems
2. Domain configuration issues
3. CORS issues

## Solution

Updated the frontend services to use Vite's proxy in development mode:

### Files Modified:

1. **`resources/js/services/authService.ts`**

    - Changed `baseURL` to use `/api` in development, `https://sellzaki.local/api` in production
    - Added URL conversion logic in `authenticatedRequest` method

2. **`resources/js/services/return/ReturnAPI.ts`**

    - Updated `baseURL` to use proxy in development

3. **`resources/js/config/api.ts`**
    - Updated `BASE_URL` to use empty string in development

### How It Works:

-   **Development**: Frontend makes requests to `/api/...` which Vite proxies to `https://sellzaki.local`
-   **Production**: Frontend makes direct requests to `https://sellzaki.local/api/...`

### Vite Proxy Configuration:

```typescript
proxy: {
  '/api': {
    target: 'https://sellzaki.local',
    changeOrigin: true,
    secure: false, // Ignores SSL certificate issues
    rewrite: (path) => path,
  }
}
```

## Testing

✅ API endpoints are accessible via proxy  
✅ Promotion system is working correctly  
✅ Network errors are resolved  
✅ Authentication is working properly

## Usage

The fix is automatic - no changes needed in the application code. The services will automatically use the appropriate URL based on the environment.

## Verification

To verify the fix is working:

1. Start the development server: `npm run dev`
2. Open the browser console
3. Look for API calls being made to `/api/...` instead of `https://sellzaki.local/api/...`
4. Check that promotion application works without network errors
