Frontend Guide
Location: frontend/
Key Concepts
- Next.js App Router
- Centralized API client:
frontend/lib/api-client.ts- Sets
baseURLfromNEXT_PUBLIC_API_URL - Injects Authorization and
x-organization-idheaders
- Sets
- OAuth success UIs for ads platforms under
frontend/app/oauth/*/success/page.tsx - Google Ads account selector:
frontend/components/google-ads-account-selector.tsx
Important Files
lib/api-client.ts— Axios client with interceptorsapp/oauth/google-ads/success/page.tsx— parses tokens from URL, opens account selection, posts to backend to create accountcomponents/google-ads-account-selector.tsx— fetches available accounts from/api/google-ads/auth/available-accounts
Conventions
- Use
apiClientfor API calls so auth/org headers are applied - Use
use clientfor components needing browser APIs/localStorage
Troubleshooting
- If API calls fail with 401 or missing org, ensure the request uses
apiClientand an organization is selected. - For Google Ads account creation, prefer
apiClient.post('/api/google-ads/accounts/create', ...)instead of raw fetch.