How Free Provider handles authentication, secrets, cookies, and logging — and what operators should be aware of.
- Generated on first run and stored in
.api-key(or read fromOPENAI_API_KEYenv var). - Sent by clients as
Authorization: Bearer <key>. - Compared via simple string equality in
server/middleware/auth.mjs. - Not rotated automatically — rotate manually by editing
.api-keyor changingOPENAI_API_KEY.
Treat the key like any bearer token: keep it out of logs and don't share publicly.
An optional client/cookies.json can unlock authenticated features:
[
{ "name": "__Secure-next-auth.session-token", "value": "..." },
{ "name": "cf_clearance", "value": "..." }
]- Format: array of
{ name, value }objects (seeclient/cookies.json.example). - Stored in plaintext on disk — treat like a session cookie / credential.
- Only required for endpoints that need an authenticated ChatGPT session.
Proxy URLs may contain credentials (socks5://user:pass@host:1080). They are configured via:
- The
PROXY_URLSenvironment variable, or - A
PROXIES.txt-style file (defaultclient/proxies.txt).
Treat the proxy list like a secret: put it in .env (gitignored) or client/proxies.txt (gitignored) — commit only the proxies.txt.example template. Credentials are never written to logs. If you expose the server publicly, rotate proxy credentials if they leak via any other route.
Every chat request is logged to both stdout and server/chat.log:
{"timestamp":"2026-09-13T08:16:17.749Z","type":"completion","stream":true,"model":"gpt-4o","user":["Say hi"],"assistant":"Hi there!"}Fields:
| Field | Type | Description |
|---|---|---|
timestamp |
ISO 8601 | When the completion finished |
type |
"completion" |
Always this value |
stream |
boolean |
True if SSE streaming was used |
model |
string | Model id from the request |
user |
string[] |
User messages from the request |
assistant |
string | Full assistant response |
error |
string/null | Error message if the request failed |
- The API key (headers are stripped)
- ChatGPT cookies
- Upstream request/response headers (only bodies)
chat.log is a plain append-only file — no rotation is performed by the server. For production deployments, hook up a log rotator or ship to a collector.
| Secret | Location | Rotation |
|---|---|---|
| API key | .api-key / OPENAI_API_KEY env |
Manual |
| ChatGPT cookies | client/cookies.json |
Export new cookies from browser |
| Per-request conversation state | In-memory only (ChatGPT instance) |
Auto-reset per request |
| Risk | Mitigation |
|---|---|
| Unauthorized API calls | Bearer token required on all /v1/* endpoints |
| Key leakage via logs | Keys never written to chat.log or stdout |
| Cookie theft | Store cookies file with restricted permissions; don't commit to VCS |
| Upstream IP blocking / Cloudflare | Server runs locally; operator controls network |
| Log injection / tampering | Log entries are JSON-stringified; consumer should parse safely |
| CSRF / XSS on web UI | No cookies used for UI auth; static file + token-only API |
| Log PII | User & assistant text is written as-is; be mindful of sensitive data in chats |
-
OPENAI_API_KEYis set to a strong, random string -
.api-keyandclient/cookies.jsonare gitignored - Log file
server/chat.logis monitored / rotated - Server runs on a trusted network (no public exposure without TLS + auth)
- If exposing publicly, terminate TLS at a reverse proxy (nginx/Traefik/Caddy)