bug: team API calls return 401 — server-side loads missing Authorization header #18
Labels
No labels
domain:backend
domain:devops
domain:frontend
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/westside-landing#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lineage
plan-2026-03-08-tryout-prep→ Phase 10b (Frontend — Admin draft board + coach filtered roster)Deployment validation found both team pages non-functional in production.
Repo
forgejo_admin/westside-appUser Story
As an admin
I want the team draft board and public teams page to load team data
So that I can assign players to teams and coaches can see their rosters
Context
Playwright E2E validation of the deployed stack revealed that
/teams(public) and/admin/teams(admin draft board) both show "Basketball API not reachable. Data unavailable." with 0 teams, 0 players.basketball-api logs confirm the requests arrive but return 401 Unauthorized:
The team endpoints on basketball-api require admin/coach JWT authentication via
Authorization: Bearer {token}. The westside-app server-side load functions (+page.server.js) call these endpoints WITHOUT passing the access token fromevent.locals.accessToken.Other routes work fine —
/adminusesfetchRoster()which hits the public/api/roster/{tenant}endpoint (no auth needed)./admin/usersuses the Keycloak Admin API with its own token. The team endpoints are the only ones that require basketball-api JWT auth and don't get it.Two routes affected:
/admin/teams— admin IS authenticated,event.locals.accessTokenis available but not passed in fetch headers/teams— public route, no access token available. This route either needs basketball-api to expose a public team listing endpoint, OR the page should require auth and use the session tokenFile Targets
Files the agent should modify:
src/routes/admin/teams/+page.server.js— addAuthorization: Bearer ${event.locals.accessToken}header to all basketball-api fetch calls in the load functionsrc/routes/teams/+page.server.js— either add auth requirement and pass token, OR use a different endpoint strategysrc/lib/server/api.js— if team fetch functions exist here, update them to accept and pass an auth token parameterFiles the agent should NOT touch:
src/auth.js— auth config is correctsrc/hooks.server.js— token extraction works correctlyAcceptance Criteria
/admin/teamsloads team data when logged in as admin (currently shows "Basketball API not reachable")/admin/teams"New Team" form creates a team successfully/teamspublic page shows team listing (decide: require auth, or add public endpoint)/coachpage still works (coach team filtering via/api/teams/mine)event.localsonly)Test Expectations
/admin/teamsas admin → teams data loads/coachpage still renders rosterConstraints
event.locals.accessToken). Never serialize to browser session./admin/users/+page.server.jswhich successfully passes Keycloak admin credentials/coach/+page.server.jsalready callsfetchMyTeam(accessToken)— use the same pattern for the other team pages/teamspublic route: prefer requiring auth over creating a new public endpoint. The team listing isn't sensitive but consistency matters.Checklist
Related
project-westside-basketball— Phase 10b deployment validation failure