thunderbolt icon indicating copy to clipboard operation
thunderbolt copied to clipboard

feat: universal proxy (new approach)

Open cjroth opened this issue 6 months ago • 3 comments

[!NOTE] High Risk High risk because it changes security-sensitive proxy/CORS behaviour (SSRF protections, header forwarding, redirect handling) and introduces a new WS proxy path; mistakes could leak credentials or open SSRF vectors.

Overview Switches the backend to a new universal proxy implementation: /v1/proxy now supports header passthrough via X-Proxy-Passthrough-*, redirect controls, streaming with caps/timeouts, SSRF/DNS pinning, and adds a new /v1/proxy/ws relay with subprotocol-encoded targets.

Adds proxy observability via proxy_request/proxy_ws_relay structured logs and OpenTelemetry span attributes, explicitly redacting full URLs/credentials while recording hostname, bytes, duration, status, and categorical error types.

Introduces new authenticated APIs: /v1/search (Exa-backed, normalises results to HTTPS and derives favicons) and /v1/preview (POST-only OG metadata extraction with HTTPS image upgrade and per-user 10‑minute private caching), plus new e2e tests.

Removes the old /pro/proxy, /pro/link-preview, and /mcp-proxy routes and their tests, updates CORS to allowedHeaders: true (echo requested headers) and refreshes corsExposeHeaders defaults/docs/env examples accordingly; also tweaks auth creation for test DI, sets Better Auth baseURL, and adjusts dev tooling/lint globals/logger exports.

Reviewed by Cursor Bugbot for commit c214826744a06192c9ad5f931e1af6c49d79c2b2. Bugbot is set up for automated code reviews on this repo. Configure here.

cjroth avatar May 06 '26 04:05 cjroth

Semgrep Security Scan

No security issues found.

github-actions[bot] avatar May 06 '26 04:05 github-actions[bot]

PR Metrics

Metric Value
Lines changed (prod code) +2313 / -1266
JS bundle size (gzipped) :green_circle: 1.03 MB → 1.02 MB (-3.6 KB, -0.3%)
Test coverage :green_circle: 72.06% → 72.22% (+0.2%)
Performance (preview) Preview not ready — Render deploy may have timed out
Accessibility —
Best Practices —
SEO —

Updated Fri, 22 May 2026 17:27:36 GMT · run #1575

github-actions[bot] avatar May 06 '26 04:05 github-actions[bot]

Preview environment destroyed 🧹

Stack preview-pr-837 and its Cloudflare subdomain have been cleaned up.

github-actions[bot] avatar May 06 '26 19:05 github-actions[bot]