File display is truncated and no line numbers are shown if using a relative URL since GitLab 16.7
Summary
In self-hosted instances, when using a relative URL (http://instance.domain/relative), the displaying of files is truncated and no line numbers are shown.
A similar issue was reported in #432793 (closed), although this one only mentions gitlab.com, which does not use relative URL.
Steps to reproduce
Start a GitLab instance with a relative URL, for instance:
services:
web:
image: 'gitlab/gitlab-ce:16.8.2-ce.0'
restart: always
hostname: '127.0.0.1'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://127.0.0.1/relative'
ports:
- '80:80'
- '443:443'
- '22:22'
Create a new project, upload or create a new file and display it. From what I see, markdown is interpreted and does not get affected but any other type such as source code or a plain text file causes the display block to be truncated if the file is large enough (> 50 lines) and lines are not shown. Links to line (e.g., #L42
) are also broken.
The browser also throws this error. It seems that it tries to load some asset file without prepending the relative
path.