Skip to content

Add API auth seamline and minimal Claude proxy#425

Merged
BunsDev merged 2 commits intomainfrom
copilot/create-auth-router-proxy
Apr 13, 2026
Merged

Add API auth seamline and minimal Claude proxy#425
BunsDev merged 2 commits intomainfrom
copilot/create-auth-router-proxy

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

What Changed

Creates a dedicated auth seamline under the API layer so auth HTTP flows are no longer embedded in wsServer. Adds a minimal Claude-compatible Anthropic proxy, modeled on claude-proxy, behind /api/auth.

  • API seamline

    • Added apps/server/src/api/router.ts to centralize /api/* handling.
    • Moved auth-related HTTP routing out of the monolithic server request path.
  • Auth router

    • Added apps/server/src/api/authRouter.ts.
    • Preserved the existing pairing flow at /api/pairing.
    • Added /api/auth/pairing as the auth-scoped route.
  • Minimal Claude proxy

    • Added POST /api/auth/anthropic/v1/messages.
    • Forwards requests to Anthropic with:
      • anthropic-beta: claude-code-20250219
      • preserved x-api-key
      • preserved anthropic-version
      • Claude Code system prompt injected into system
    • Added /api/auth/anthropic/health and /api/auth/anthropic/status.
  • Server wiring

    • Updated apps/server/src/wsServer.ts to delegate /api traffic through the new router instead of handling pairing inline.
  • Coverage

    • Added focused router tests for pairing compatibility, Anthropic proxy envelope behavior, and API 404s.
const response = await fetch("/api/auth/anthropic/v1/messages", {
  method: "POST",
  headers: {
    "content-type": "application/json",
    "x-api-key": "...",
    "anthropic-version": "2023-06-01",
  },
  body: JSON.stringify({
    model: "claude-sonnet-4-20250514",
    messages: [{ role: "user", content: "Hello" }],
  }),
});

Why

The issue was not the proxy behavior itself; it was that auth and proxy concerns had no clean seam under the API layer. This change creates that seam first, then hangs a minimal Claude/Anthropic proxy off it so auth routing can evolve without growing more logic inside wsServer.

UI Changes

No UI changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Copilot AI and others added 2 commits April 10, 2026 17:35
Agent-Logs-Url: https://github.com/OpenKnots/okcode/sessions/6cd8bf08-8ada-493c-b8a5-fc5b9a543673

Co-authored-by: BunsDev <68980965+BunsDev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenKnots/okcode/sessions/6cd8bf08-8ada-493c-b8a5-fc5b9a543673

Co-authored-by: BunsDev <68980965+BunsDev@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
okcode-marketing Ready Ready Preview Apr 13, 2026 2:50am
v0-compute-the-platform-to-build Error Error Open in v0 Apr 13, 2026 2:50am

@BunsDev BunsDev marked this pull request as ready for review April 13, 2026 02:50
@BunsDev BunsDev merged commit 0ca3a4b into main Apr 13, 2026
3 of 4 checks passed
@github-actions github-actions Bot added size:L vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants