Skip to content

Read the app JWT from X-Refetch-JWT; Cloud's executor overwrites Authorization - #14

Merged
lohanidamodar merged 1 commit into
mainfrom
fix/app-api-jwt-header
Nov 8, 2026
Merged

lohanidamodar merged 1 commit into
mainfrom
fix/app-api-jwt-header

Conversation

@lohanidamodar

Copy link
Copy Markdown
Collaborator

Follow-up to #13. Every /api/app/* call from the app answered 401 in production, although the same calls worked locally.

Root cause

On Appwrite Cloud the edge executor overwrites the request's Authorization header with its own Basic opr:<secret> credential before the request reaches the site (edge src/Edge/K8s/Runner.php). The app's Bearer <jwt> never arrives. Verified from the app on a phone: the same JWT returns 200 from Appwrite's /v1/account and 401 from https://refetch.io/api/app/session. The website is unaffected because establishSession takes the JWT in the request body.

Fix

The routes read the JWT from X-Refetch-JWT (appToken in src/lib/app-api.ts), falling back to Authorization: Bearer for local runs without the proxy. docs/APP_API.md updated. The app sends the new header in refetch-io/refetch_flutter (fix/app-jwt-header).

Checks

  • pnpm test: 127 passed (5 new for appToken, including the executor's Basic credential being ignored)
  • pnpm typecheck: clean

🤖 Generated with Claude Code

On Appwrite Cloud the edge executor overwrites the request's
Authorization header with its own `Basic opr:<secret>` (edge
src/Edge/K8s/Runner.php) before it reaches the site, so the app's
Bearer token never arrived and every /api/app/* call answered 401.
Verified from the app: the same JWT returns 200 from Appwrite's
/v1/account but 401 from /api/app/session.

The routes now read the JWT from X-Refetch-JWT and keep Bearer only as a
fallback for local runs without the proxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@appwrite

appwrite Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Refetch

Project ID: 63ef1792594ff4f50de2

Sites (1)
Site Status Logs Preview QR
 App
688e6ad00039239f1ecc
Ready Ready View Logs Preview URL QR Code
Functions (4)
Function ID Status Logs
 Readme 68a18eba0012c97a0017 Failed Failed View Logs
 Scout 689bd7b6002c5d783925 Ready Ready View Logs
 Algorithm 689b8b5f00075917c520 Ready Ready View Logs
 Enhancement 6897c57600169dfb0b92 Ready Ready View Logs

Tip

Environment variable changes require redeployment to take effect

@lohanidamodar
lohanidamodar merged commit 93cc15e into main Nov 8, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant