#src/pages/api/auth
2 messages · Page 1 of 1 (latest)
In Astro, routes are created automatically from the files in src/pages/ using file-based routing. There is no extra routing config. [Routing guide]
For API routes (“server endpoints”), the same rule applies: any .ts/.js file under src/pages becomes an endpoint whose URL matches its path. [Static file endpoints]
So for:
src/pages/api/auth/signin.ts
src/pages/api/auth/signout.ts
src/pages/api/auth/register.ts
Astro automatically exposes these as:
POST /api/auth/register→src/pages/api/auth/register.ts[Supabase auth endpoints]POST /api/auth/signin→src/pages/api/auth/signin.ts[Supabase auth endpoints]GET /api/auth/signout→src/pages/api/auth/signout.ts[Supabase auth endpoints]
When the browser (or fetch()) makes a request to /api/auth/signin, Astro matches that URL to the file path under src/pages/ and calls the exported function for the HTTP method (GET, POST, etc.). [HTTP methods; Route priority]