Add configurable PreserveServerUrlPath option for reverse proxy support#74
Draft
Add configurable PreserveServerUrlPath option for reverse proxy support#74
Conversation
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>
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>
Copilot
AI
changed the title
[WIP] Fix DeepLClientOptions.ServerUrl handling for reverse proxy
Add configurable PreserveServerUrlPath option for reverse proxy support
Mar 31, 2026
DeeJayTC
reviewed
Mar 31, 2026
| /// 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; |
Member
There was a problem hiding this comment.
actually....not sure wether the current behaviour is true or false...
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
ServerUrlcontains 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 viaPreserveServerUrlPathso users can opt out if needed.Changes
TranslatorOptions: NewPreserveServerUrlPathproperty (defaulttrue), inherited byDeepLClientOptionsDeepLHttpClient: Centralized URI construction intoResolveUri()— whenfalse, prepends/to force RFC 3986 absolute-path resolution, discarding the base pathtrue/falsebehavior viaTranslatorOptionsandDeepLClientOptionsUsage