Skip to content

Multi-domain support, ROOT_URL problem, use relative URLs in templates instead of absolute URLs #19345

@wxiaoguang

Description

@wxiaoguang

At the moment, Gitea users must set ROOT_URL correctly in app.ini, otherwise many URLs on the web UI will be wrong, which makes the web UI doesn't work properly (CSRF tokens and cookies can not work across domains)

The ROOT_URL must be set to the full URL which the users visit, with correct scheme(eg: https://the-gitea-domain/) and correct sub path if it is used (eg: https://the-gitea-domain/my-gitea-path/).

New code should always use relative URLs for Web UI.


Many maintainers have answered the issues about incorrect ROOT_URL again and again.

Using HTMLURL(and other absolute URLs) in templates is the root case that Gitea can only serve web under ROOT_URL.

That's why we have to force users to set ROOT_URL correctly.

If all URLs in template can be refactored to use Relative URL correctly, then we do not need to force users set ROOT_URL correctly again and again.

The ROOT_URL is still needed because for example, some webhooks need the absolute URL for external systems, and Gitea should show absolute URL on the UI for clone link, etc.

Related:

Some more related:

The PR to detect the problem:

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtopic/uiChange the appearance of the Gitea UItype/proposalThe new feature has not been accepted yet but needs to be discussed first.type/refactoringExisting code has been cleaned up. There should be no new functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions