Recent "Url scheme" commit breaks redirects (404s) when the "root url" is in a subdirectory #1195

Closed
opened 2025-11-02 03:52:04 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @wyattoday on GitHub (Oct 30, 2017).

  • Gitea version (or commit ref): 513375c429
  • Git version: 2.14.3
  • Operating system: Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

Use a ROOT_URL in your config in a directory other than the "root" directory. For example, https://example.com/git/

The problem is that the "Commits" link at the top of a repository view has the form /BASE_DIR/COMPANY_NAME/REPOSITORY_NAME/commits/master when it should be /BASE_DIR/COMPANY_NAME/REPOSITORY_NAME/commits/branch/master (as per the latest commit: 513375c429 ).

However, if you click the current "Commits" link it incorrect drops the "subdirectory" part of the URL. Meaning Gitea currently incorrectly redirects to /COMPANY_NAME/REPOSITORY_NAME/commits/branch/master instead of /BASE_DIR/COMPANY_NAME/REPOSITORY_NAME/commits/branch/master. Meaning, the current redirection code assumes the gitea installation is in the root directory. Which, for us that's not true.

The breaking changes were in this commit: 513375c429

Originally created by @wyattoday on GitHub (Oct 30, 2017). - Gitea version (or commit ref): https://github.com/go-gitea/gitea/commit/513375c429435ba60a667b219bdfb00e5b760b38 - Git version: 2.14.3 - Operating system: Linux - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: ## Description Use a `ROOT_URL` in your config in a directory other than the "root" directory. For example, https://example.com/git/ The problem is that the "Commits" link at the top of a repository view has the form `/BASE_DIR/COMPANY_NAME/REPOSITORY_NAME/commits/master` when it should be `/BASE_DIR/COMPANY_NAME/REPOSITORY_NAME/commits/branch/master` (as per the latest commit: https://github.com/go-gitea/gitea/commit/513375c429435ba60a667b219bdfb00e5b760b38 ). However, if you click the current "Commits" link it incorrect drops the "subdirectory" part of the URL. Meaning Gitea currently incorrectly redirects to `/COMPANY_NAME/REPOSITORY_NAME/commits/branch/master` instead of `/BASE_DIR/COMPANY_NAME/REPOSITORY_NAME/commits/branch/master`. Meaning, the current redirection code assumes the gitea installation is in the root directory. Which, for us that's not true. The breaking changes were in this commit: https://github.com/go-gitea/gitea/commit/513375c429435ba60a667b219bdfb00e5b760b38
GiteaMirror added the issue/regressiontype/bug labels 2025-11-02 03:52:04 -06:00
Author
Owner

@lunny commented on GitHub (Oct 31, 2017):

It seems

if setting.Protocol == setting.FCGI {
		m.SetURLPrefix(setting.AppSubURL)
	}

Should be

m.SetURLPrefix(setting.AppSubURL)

And after that, Commits is OK. But Branches will panic.

@lunny commented on GitHub (Oct 31, 2017): It seems ```Go if setting.Protocol == setting.FCGI { m.SetURLPrefix(setting.AppSubURL) } ``` Should be ```Go m.SetURLPrefix(setting.AppSubURL) ``` And after that, `Commits` is OK. But `Branches` will panic.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1195