CORS Solution - Browser Console Method
How to Test the API (Avoiding CORS Issues):
  1. Open your browser's Developer Tools (F12)
  2. Go to the Console tab
  3. Copy and paste one of the code snippets below
  4. Press Enter to execute
Test Code Snippets:
1. Test All Reports (Event ID: 1)
fetch('../api/reports_api.php?event_id=1&type=all')
  .then(response => response.json())
  .then(data => {
    console.log('API Response:', data);
    console.table(data.reports);
    console.log('Statistics:', data.stats);
  })
  .catch(error => console.error('Error:', error));
2. Test Start Lists Only (Event ID: 1)
fetch('../api/reports_api.php?event_id=1&type=start_list')
  .then(response => response.json())
  .then(data => {
    console.log('Start Lists:', data.grouped_reports.start_list);
    data.reports.forEach(report => {
      console.log(`${report.name}: ${report.urls.pdf}`);
    });
  })
  .catch(error => console.error('Error:', error));
3. Test Summary Tables Only (Event ID: 1)
fetch('../api/reports_api.php?event_id=1&type=summary_table')
  .then(response => response.json())
  .then(data => {
    console.log('Summary Tables:', data.grouped_reports.summary_table);
    data.reports.forEach(report => {
      console.log(`${report.name} - Heat: ${report.heat_badge}`);
      console.log('URLs:', report.urls);
    });
  })
  .catch(error => console.error('Error:', error));
4. Custom Event ID Test
// Change the event_id value below
const eventId = 3; // Change this to your event ID
const filterType = 'all'; // or 'start_list' or 'summary_table'

fetch(`../api/reports_api.php?event_id=${eventId}&type=${filterType}`)
  .then(response => {
    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${response.statusText}`);
    }
    return response.json();
  })
  .then(data => {
    console.log('=== API RESPONSE ===');
    console.log('Success:', data.success);
    console.log('Event ID:', data.event_id);
    console.log('Filter Type:', data.filter_type);
    console.log('Statistics:', data.stats);
    console.log('=== REPORTS ===');
    console.table(data.reports);
    console.log('=== GROUPED REPORTS ===');
    console.log('Start Lists:', data.grouped_reports.start_list);
    console.log('Summary Tables:', data.grouped_reports.summary_table);
  })
  .catch(error => {
    console.error('=== ERROR ===');
    console.error('Error details:', error);
  });
Alternative Testing Methods:
  • PHP Test Page: Open PHP Test Page
  • Direct API Access: Open API Directly
  • Use a tool like Postman to test the API endpoints
  • Use curl from command line: curl "http://localhost/stylescore2025/htdocs/v2/api/reports_api.php?event_id=1"
CORS Configuration

The API now includes proper CORS headers to allow cross-origin requests:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
These headers should resolve CORS issues when accessing the API from different origins.