Skip to main content

API Integration Guide

Environment Variables

Contoh baseline:

  • NEXT_PUBLIC_API_BASE_URL=http://localhost:8000/api/v1
  • LARAVEL_OPENAPI_URL=http://localhost:8000/docs/v1/openapi.yaml

Integration Workflow

  1. Backend update endpoint + OpenAPI spec.
  2. Regenerate frontend API client/types (if a generator is used).
  3. Implement service/use-case di layer API frontend.
  4. Tambahkan error handling + loading state + fallback UI.
  5. Jalankan quality gate.

Error Handling Rules

  • Selalu tangani status 4xx/5xx secara eksplisit.
  • Jangan expose raw server error ke UI user.
  • Logging error teknis ke console/monitoring channel internal.

Auth Notes

If using cookie-based auth (e.g., Sanctum):

  • Backend CORS must allow the frontend origin.
  • withCredentials aktif di HTTP client.
  • Use a consistent host in local dev to avoid cookie issues.