fix: Context.BaseURL() discards path when HOST_MODE=single#1502
Open
tejasae-afk wants to merge 1 commit intogetfider:mainfrom
Open
fix: Context.BaseURL() discards path when HOST_MODE=single#1502tejasae-afk wants to merge 1 commit intogetfider:mainfrom
tejasae-afk wants to merge 1 commit intogetfider:mainfrom
Conversation
When HOST_MODE=single and BASE_URL contains a path component (e.g. https://example.com/feedback), Context.BaseURL() was returning only the scheme+host (https://example.com), discarding the path. This broke all server-side redirects and the baseURL injected into the frontend because handlers call c.BaseURL() — not the package-level web.BaseURL() function, which already handled single-host mode correctly. The fix aligns Context.BaseURL() with web.BaseURL(): when in single-host mode it returns env.Config.BaseURL directly. The multi-tenant path is unchanged. Fixes getfider#1452
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
HOST_MODE=singleandBASE_URLcontains a path component (e.g.https://example.com/feedback),Context.BaseURL()was returning only the scheme and host (https://example.com), silently dropping the path.This broke server-side redirects (sign-in, OAuth callbacks, delete-post flows, etc.) and the
baseURLvalue injected into the frontend via the renderer — all of which callc.BaseURL(). Users hosted behind a reverse proxy under a sub-path would land on the root of the site instead of the configured sub-path after any redirect.The root cause is a split between two
BaseURLimplementations. The package-levelweb.BaseURL(ctx)already handled single-host mode correctly by returningenv.Config.BaseURLintact, butContext.BaseURL()always delegated toRequest.BaseURL(), which only constructsscheme://host:portwith no path.The fix is one extra check at the top of
Context.BaseURL():This makes
Context.BaseURL()consistent withweb.BaseURL(). Multi-tenant behaviour is unchanged.A test covering the single-host-with-path case is included.
Fixes #1452.
you know the codebase far better than I do, happy to adjust anything here.