Skip to content

Conversation

@XYenon
Copy link
Contributor

@XYenon XYenon commented Nov 1, 2025

πŸ’» Change Type

  • ✨ feat
  • πŸ› fix
  • ♻️ refactor
  • πŸ’„ style
  • πŸ‘· build
  • ⚑️ perf
  • βœ… test
  • πŸ“ docs
  • πŸ”¨ chore

πŸ”€ Description of Change

Add INTERNAL_APP_URL environment variable to bypass CDN/proxy for internal operations like embedding and file chunking. Falls back to APP_URL if not set.

πŸ§ͺ How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed

Summary by Sourcery

Add the INTERNAL_APP_URL environment variable to support bypassing CDN or proxy for internal server-to-server calls, update the async caller to use this URL, and include corresponding documentation and tests.

New Features:

  • Introduce INTERNAL_APP_URL environment variable with fallback to APP_URL for internal server-to-server calls
  • Update async server client to use INTERNAL_APP_URL for bypassing CDN or proxy

Documentation:

  • Document INTERNAL_APP_URL configuration and usage in Docker Compose self-hosting guides (English and Chinese)

Tests:

  • Add tests to verify INTERNAL_APP_URL fallback behavior and explicit override scenarios

@vercel
Copy link

vercel bot commented Nov 1, 2025

@XYenon is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 1, 2025

Reviewer's Guide

This PR introduces a new INTERNAL_APP_URL environment variable (falling back to APP_URL) for internal server-to-server calls, updates the application configuration and async client to use it, adds corresponding tests, and documents the change in the Docker Compose guides.

Sequence diagram for async server-to-server call using INTERNAL_APP_URL

sequenceDiagram
  participant S as "Async Caller (Server)"
  participant E as "LobeChat Server"
  S->>E: POST /trpc/async (using INTERNAL_APP_URL)
  E-->>S: Response
Loading

Class diagram for updated app environment configuration

classDiagram
  class AppEnv {
    +APP_URL: string
    +INTERNAL_APP_URL: string
    +getAppConfig()
  }
  AppEnv <|-- getAppConfig
Loading

File-Level Changes

Change Details Files
Add INTERNAL_APP_URL support in application configuration
  • Define INTERNAL_APP_URL constant with fallback to APP_URL
  • Include INTERNAL_APP_URL in the Zod schema and getAppConfig output
  • Enforce fallback behavior when INTERNAL_APP_URL is unset
src/envs/app.ts
Use INTERNAL_APP_URL for server-to-server async client
  • Update createAsyncServerClient to join URL with INTERNAL_APP_URL
  • Replace previous APP_URL usage in async router caller
src/server/routers/async/caller.ts
Add tests validating INTERNAL_APP_URL behavior
  • Test default fallback to APP_URL
  • Test explicit INTERNAL_APP_URL override
  • Test precedence when both URLs are set
  • Test handling of localhost internal URLs
src/envs/__tests__/app.test.ts
Document INTERNAL_APP_URL in Docker Compose guides
  • Add explanatory section and usage examples in English guide
  • Add matching section and examples in Chinese guide
  • Provide callouts and configuration options for Docker deployments
docs/self-hosting/server-database/docker-compose.mdx
docs/self-hosting/server-database/docker-compose.zh-CN.mdx
Add test suite for async caller behavior
  • Introduce new test file for createAsyncServerClient
  • Verify routing logic uses INTERNAL_APP_URL
src/server/routers/async/__tests__/caller.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 1, 2025
@lobehubbot
Copy link
Member

πŸ‘ @XYenon

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.

@gru-agent
Copy link
Contributor

gru-agent bot commented Nov 1, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail 4961580 βœ… Finished

History Assignment

Files

File Pull Request
src/server/routers/async/caller.ts ❌ Failed (I failed to setup the environment.)

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/server/routers/async/__tests__/caller.test.ts:3` </location>
<code_context>
+# to bypass CDN/proxy. If not set, defaults to APP_URL.
+# Example: INTERNAL_APP_URL=http://localhost:3210
 AUTH_URL=http://localhost:3210/api/auth

 # Postgres related, which are the necessary environment variables for DB
</code_context>

<issue_to_address>
**issue (testing):** No test implementation found for async caller logic.

Please implement tests to ensure server-to-server calls use INTERNAL_APP_URL and fallback to APP_URL as needed, and include cases for error handling with missing or malformed URLs.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click πŸ‘ or πŸ‘Ž on each comment and I'll use the feedback to improve your reviews.

@@ -0,0 +1,121 @@
// @vitest-environment node
import { describe, expect, it, vi } from 'vitest';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): No test implementation found for async caller logic.

Please implement tests to ensure server-to-server calls use INTERNAL_APP_URL and fallback to APP_URL as needed, and include cases for error handling with missing or malformed URLs.

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 80.73%. Comparing base (d79ffa3) to head (91f31b8).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #9960      +/-   ##
==========================================
- Coverage   81.90%   80.73%   -1.17%     
==========================================
  Files         879      896      +17     
  Lines       56224    57354    +1130     
  Branches     7724     8750    +1026     
==========================================
+ Hits        46051    46306     +255     
- Misses      10173    11048     +875     
Flag Coverage Ξ”
app 72.99% <100.00%> (-1.67%) ⬇️
database 98.35% <ΓΈ> (ΓΈ)
packages/agent-runtime 98.37% <ΓΈ> (ΓΈ)
packages/context-engine 93.79% <ΓΈ> (ΓΈ)
packages/electron-server-ipc 93.76% <ΓΈ> (ΓΈ)
packages/file-loaders 92.21% <ΓΈ> (ΓΈ)
packages/model-bank 100.00% <ΓΈ> (ΓΈ)
packages/model-runtime 92.19% <ΓΈ> (ΓΈ)
packages/prompts 77.29% <ΓΈ> (ΓΈ)
packages/python-interpreter 96.50% <ΓΈ> (ΓΈ)
packages/utils 94.29% <ΓΈ> (ΓΈ)
packages/web-crawler 96.81% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Ξ”
Store 73.13% <ΓΈ> (ΓΈ)
Services 55.36% <ΓΈ> (ΓΈ)
Server 74.36% <100.00%> (-3.96%) ⬇️
Libs 36.27% <ΓΈ> (-0.40%) ⬇️
Utils 83.03% <ΓΈ> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@XYenon XYenon force-pushed the feat/internal-app-url branch from 4961580 to 2657b06 Compare November 1, 2025 09:58
@XYenon XYenon changed the title ✨ feat: add INTERNAL_APP_URL for server-to-server async calls ✨ feat: add INTERNAL_APP_URL for server-to-server calls Nov 1, 2025
@XYenon XYenon force-pushed the feat/internal-app-url branch 2 times, most recently from da4d7a6 to 356ac07 Compare November 1, 2025 11:36
@arvinxx
Copy link
Member

arvinxx commented Nov 4, 2025

@XYenon please rebase the next ~ thx

@arvinxx arvinxx changed the title ✨ feat: add INTERNAL_APP_URL for server-to-server calls ✨ feat: add INTERNAL_APP_URL for server-to-server calls Nov 4, 2025
XYenon and others added 3 commits November 4, 2025 22:41
Add INTERNAL_APP_URL environment variable to bypass CDN/proxy for internal operations like embedding and file chunking. Falls back to APP_URL if not set.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Add documentation for INTERNAL_APP_URL environment variable in:
- docker-compose .env.example
- Docker Compose deployment guide (English and Chinese)

Explains how to bypass CDN/proxy for server-to-server operations.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Add comprehensive test coverage for INTERNAL_APP_URL:
- Test fallback behavior to APP_URL when INTERNAL_APP_URL is not set
- Test explicit INTERNAL_APP_URL configuration
- Test localhost bypass for CDN/proxy
- Test createAsyncServerClient using INTERNAL_APP_URL
- Test authentication headers in async calls

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@XYenon XYenon force-pushed the feat/internal-app-url branch from 356ac07 to 91f31b8 Compare November 4, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants