Skip to main content

Base URL

The API base URL varies depending on the environment:
  • Production: https://autonomous.stu.nighthawkcodingsociety.com
  • Local Development: http://localhost:8888
  • Local (127.0.0.1): http://127.0.0.1:8888
The application automatically detects the hostname and selects the appropriate base URL.

Authentication

The API uses credential-based authentication with cookies:
credentials: 'include'
This ensures session cookies are sent with every request for authenticated endpoints.

CORS Configuration

All API requests use CORS mode to enable cross-origin requests:
mode: 'cors'

Common Headers

Include these headers with all API requests:
Content-Type
string
default:"application/json"
required
Media type of the request body
X-Origin
string
default:"client"
Custom header to identify the request source

Fetch Configuration

The standard fetch options used across the application:
export const fetchOptions = {
  method: 'GET',
  mode: 'cors',
  cache: 'default',
  credentials: 'include',
  headers: {
    'Content-Type': 'application/json',
    'X-Origin': 'client'
  }
};
Source: assets/js/api/config.js

Error Handling

All endpoints follow standard HTTP status codes:
  • 200: Success
  • 400: Bad Request - Invalid parameters
  • 401: Unauthorized - Authentication required
  • 404: Not Found - Resource doesn’t exist
  • 500: Internal Server Error
Error responses include a JSON body with an error field:
{
  "error": "Description of the error"
}

Rate Limiting

The API implements standard rate limiting. Check response headers for:
  • X-RateLimit-Limit
  • X-RateLimit-Remaining
  • X-RateLimit-Reset

Build docs developers (and LLMs) love