Skip to content

fix(route): update backend URL handling for internal Docker network#1459

Merged
MODSetter merged 2 commits into
mainfrom
docker-hot-patch
Jun 2, 2026
Merged

fix(route): update backend URL handling for internal Docker network#1459
MODSetter merged 2 commits into
mainfrom
docker-hot-patch

Conversation

@MODSetter
Copy link
Copy Markdown
Owner

@MODSetter MODSetter commented Jun 2, 2026

Description

Motivation and Context

FIX #

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR fixes a backend URL resolution issue for server-to-server communication within Docker containers. The route handler now prioritizes FASTAPI_BACKEND_INTERNAL_URL for internal Docker network communication (e.g., http://backend:8000) over the browser-facing URL, preventing 503 errors during authenticated Zero queries when the zero-cache system invokes this route server-side.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/app/api/zero/query/route.ts

Need help? Join our Discord

Summary by CodeRabbit

  • Chores
    • Updated the Zero query API route configuration to optimize backend communication by prioritizing internal network paths for server-to-server requests, improving performance and reliability.

MODSetter added 2 commits June 1, 2026 18:33
- Modified backend URL assignment to ensure it resolves correctly within the internal Docker network, preventing 503 errors for authenticated Zero queries.
- Added comments to clarify the routing behavior and the necessity of using the internal backend URL.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

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

Project Deployment Actions Updated (UTC)
surf-sense-frontend Ready Ready Preview, Comment Jun 2, 2026 1:35am

Request Review

@MODSetter MODSetter merged commit d0194f4 into main Jun 2, 2026
6 of 9 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f1b4176a-c7d2-4305-bdf1-949291bbfbc0

📥 Commits

Reviewing files that changed from the base of the PR and between abea00d and 97de041.

📒 Files selected for processing (1)
  • surfsense_web/app/api/zero/query/route.ts

📝 Walkthrough

Walkthrough

The zero query API route's backend URL is now derived from an internal FastAPI backend environment variable with fallbacks to external URL and a default localhost endpoint, and the URL is normalized by removing trailing slashes.

Changes

Zero Query Internal Backend Routing

Layer / File(s) Summary
Backend URL configuration with internal Docker routing
surfsense_web/app/api/zero/query/route.ts
The backendURL constant now derives from process.env.FASTAPI_BACKEND_INTERNAL_URL with fallbacks to BACKEND_URL and a default of http://localhost:8000, with trailing slash normalization applied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • MODSetter/SurfSense#1289: Directly modifies the same backendURL constant in the zero query route to add internal Docker-to-FastAPI routing via environment variables.

Poem

🐰 Through Docker's hidden lanes we roam,
The backend found a closer home—
No slashes trailing in the night,
Internal routes shine clean and bright! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docker-hot-patch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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