Auth Backend is configured entirely through environment variables. CopyDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/eggarcia98/auth-backend/llms.txt
Use this file to discover all available pages before exploring further.
.env.example to .env and fill in the values before starting the server.
Server
The runtime environment. Accepted values are
development, staging, or production. Controls logging behavior and other environment-specific settings.The port the HTTP server listens on. When deploying to Cloud Run or Docker, the container binds to
0.0.0.0 on this port.The origin URL of your frontend application (e.g.
http://localhost:3000 or https://app.example.com). This value is used to configure CORS — only requests from this origin are accepted. It is also used as the redirect destination for OAuth and password reset flows.Supabase
Auth Backend uses Supabase for user management and authentication. You need a Supabase project before you can run the server. To create a Supabase project:- Go to supabase.com and sign in.
- Click New project and enter a name and password.
- Wait for the project to provision, then go to Project Settings → API.
- Copy the three values below into your
.env.
Your Supabase project URL. Found under Project Settings → API → Project URL.
The public anonymous key for your Supabase project. Found under Project Settings → API → Project API keys → anon public.This key is safe to use in server-side code and is used for unauthenticated operations.
The service role key for your Supabase project. Found under Project Settings → API → Project API keys → service_role.This key bypasses Row Level Security and is used for admin operations such as creating and managing users.
JWT
A secret key used to sign and verify JWTs. Must be at least 32 characters long.Generate a secure value with:
OAuth providers (optional)
OAuth credentials are optional. Omit these variables if you do not need Google or Apple Sign-In..env file.
To set up Google Sign-In:
- Go to the Google Cloud Console → APIs & Services → Credentials.
- Click Create credentials → OAuth client ID (application type: Web application).
- Add the Supabase callback URL to Authorized redirect URIs:
- Copy the Client ID and Client Secret.
- In your Supabase dashboard, go to Authentication → Providers → Google, enable it, and paste the credentials.
No Google environment variables are required in the backend
.env file. All OAuth credentials are stored and managed by Supabase.Apple
To enable Apple Sign-In, you need an Apple Developer account and a Services ID.Apple Sign-In requires a registered domain and an HTTPS callback URL. It cannot be tested on
localhost without a tunnel such as ngrok.Your Apple Services ID (e.g.
com.example.app.service).Your 10-character Apple Team ID. Found in the Apple Developer portal under Membership.
The key identifier for your Apple Sign-In private key. Found under Certificates, Identifiers & Profiles → Keys.
The contents of the
.p8 private key file downloaded from the Apple Developer portal. Include the full key including the header and footer lines.CORS and cookies
CORS
CORS is configured automatically using theFRONTEND_URL variable. The server allows requests from that origin with credentials and supports the following methods: GET, POST, PUT, DELETE, and OPTIONS.
To allow multiple origins or a wildcard, you would need to modify the CORS configuration in src/app.ts:
src/app.ts
Cookies
Access and refresh tokens are stored as HTTP-only cookies. These cookies are set automatically on login and cleared on logout. They are not accessible from JavaScript, which prevents XSS-based token theft.| Cookie | Description |
|---|---|
accessToken | Short-lived JWT used to authenticate requests. |
refreshToken | Long-lived token used to obtain a new access token via POST /api/v1/auth/refresh. |