Skip to content

Add configurable PreserveServerUrlPath option for reverse proxy support#74

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-deeplclientoptions-serverurl
Draft

Add configurable PreserveServerUrlPath option for reverse proxy support#74
Copilot wants to merge 3 commits intomainfrom
copilot/fix-deeplclientoptions-serverurl

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 31, 2026

When ServerUrl contains a base path (e.g. https://proxy.example.com/deepl/), the path component is preserved during URI resolution since relative API paths don't have leading slashes. This PR makes that behavior explicitly configurable via PreserveServerUrlPath so users can opt out if needed.

Changes

  • TranslatorOptions: New PreserveServerUrlPath property (default true), inherited by DeepLClientOptions
  • DeepLHttpClient: Centralized URI construction into ResolveUri() — when false, prepends / to force RFC 3986 absolute-path resolution, discarding the base path
  • Tests: Coverage for both true/false behavior via TranslatorOptions and DeepLClientOptions

Usage

// Reverse proxy with path prefix — works by default (PreserveServerUrlPath = true)
var options = new DeepLClientOptions {
    ServerUrl = "https://proxy.example.com/deepl/"
};
// Requests go to https://proxy.example.com/deepl/v2/translate

// Opt out to resolve from server root
var options = new DeepLClientOptions {
    ServerUrl = "https://proxy.example.com/deepl/",
    PreserveServerUrlPath = false
};
// Requests go to https://proxy.example.com/v2/translate

Copilot AI and others added 2 commits March 31, 2026 08:50
Add PreserveServerUrlPath option to TranslatorOptions (defaults to true)
to control whether the ServerUrl path component is preserved when
constructing API request URIs. This makes the reverse-proxy base path
behavior configurable while maintaining backward compatibility.

When true (default): server URL paths are preserved, supporting
reverse proxy setups with path prefixes (e.g. /deepl/).
When false: API paths are resolved from the server root, ignoring
any base path in the ServerUrl.

Agent-Logs-Url: https://github.com/DeepLcom/deepl-dotnet/sessions/2a0d441f-2b85-4175-b698-d108d4e45b32

Co-authored-by: DeeJayTC <4077759+DeeJayTC@users.noreply.github.com>
@DeeJayTC DeeJayTC requested a review from JanEbbing March 31, 2026 08:53
Copilot AI changed the title [WIP] Fix DeepLClientOptions.ServerUrl handling for reverse proxy Add configurable PreserveServerUrlPath option for reverse proxy support Mar 31, 2026
Copilot AI requested a review from DeeJayTC March 31, 2026 08:53
/// a reverse proxy with a path prefix (e.g. <c>https://proxy.example.com/deepl/</c>). Set to <c>false</c> to ignore
/// the path component and resolve API paths from the server root.
/// </summary>
public bool PreserveServerUrlPath { get; set; } = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

actually....not sure wether the current behaviour is true or false...

@vernou
Copy link
Copy Markdown

vernou commented Apr 1, 2026

The commit b07280e fixes the issue #73. This PR adds a parameter to retrieve the old behavior.


I don't think it's necessary to make this behavior configurable. The old behavior is misleading, so new user will not understand the problem.

If a developper want to remove the server url path, then he can remove it before to set ServerUrlPath.

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.

DeepLClientOptions.ServerUrl don't work with base url path

3 participants