Skip to content

PDFs in Browser won't render since upgrade to 15.5 on Gitlab instances in a subdirectory

Summary

Whenever you try to open a PDF in an repository you get the error: "An error occurred while loading the file. Please try again later.".

Steps to reproduce

Use a gitlab-ce instance with a relative subdirectory (e.g. http://localhost/gitlab) and try to view a PDF from a sample repository.

Example Project

What is the current bug behavior?

Whenever you try to open a PDF in an repository you get the error: "An error occurred while loading the file. Please try again later.".

What is the expected correct behavior?

Before 15.5 Gitlab rendered every PDF directly in the browser.

Relevant logs and/or screenshots

The browser console log shows: Loading Worker from “https://OURDOMAIN.de/assets/webpack/pdfjs/pdf.worker.min.js” was blocked because of a disallowed MIME type (“text/html”).

This is not the expected URL, because we use Gitlab at a subdirectory. Opening https://OURDOMAIN.de/gitlab/assets/webpack/pdfjs/pdf.worker.min.js shows the correct JavaScript file.

Output of checks

Results of GitLab environment info

Gitlab as Docker container

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:env:info)

System information
System:
Current User:   git
Using RVM:      no
Ruby Version:   2.7.5p203
Gem Version:    3.1.6
Bundler Version:2.3.15
Rake Version:   13.0.6
Redis Version:  6.2.7
Sidekiq Version:6.4.2
Go Version:     unknown

GitLab information
Version:        15.5.2
Revision:       2165c18956e
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     12.10
URL:            https://OURDOMAIN.de/gitlab
HTTP Clone URL: https://OURDOMAIN.de/gitlab/some-group/some-project.git
SSH Clone URL:  git@OURDOMAIN.de:some-group/some-project.git
Using LDAP:     yes
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        14.12.0
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.12.0 ? ... OK (14.12.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: OK
Redis available via internal API: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes
Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
        User output sanitized. Found 30 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... yes
Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units)
Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units)
Projects have namespace: ...
6/2 ... yes
10/8 ... yes
3/9 ... yes
10/10 ... yes
10/11 ... yes
14/12 ... yes
15/13 ... yes
15/14 ... yes
10/15 ... yes
16/16 ... yes
16/18 ... yes
10/19 ... yes
16/22 ... yes
6/23 ... yes
21/26 ... yes
3/28 ... yes
16/29 ... yes
16/30 ... yes
21/32 ... yes
21/33 ... yes
3/34 ... yes
16/35 ... yes
10/36 ... yes
3/37 ... yes
10/38 ... yes
6/39 ... yes
10/40 ... yes
14/43 ... yes
6/46 ... yes
16/47 ... yes
3/51 ... yes
3/52 ... yes
24/53 ... yes
24/54 ... yes
24/55 ... yes
24/56 ... yes
24/57 ... yes
24/58 ... yes
24/59 ... yes
24/60 ... yes
24/61 ... yes
24/62 ... yes
21/63 ... yes
16/64 ... yes
16/65 ... yes
16/66 ... yes
16/70 ... yes
10/71 ... yes
10/72 ... yes
10/73 ... yes
10/74 ... yes
10/76 ... yes
10/77 ... yes
10/78 ... yes
15/81 ... yes
10/82 ... yes
16/83 ... yes
14/84 ... yes
3/85 ... yes
16/86 ... yes
21/87 ... yes
3/89 ... yes
3/90 ... yes
6/91 ... yes
3/92 ... yes
10/93 ... yes
16/94 ... yes
3/95 ... yes
10/96 ... yes
3/97 ... yes
21/98 ... yes
25/100 ... yes
3/101 ... yes
10/103 ... yes
24/104 ... yes
26/105 ... yes
3/106 ... yes
21/107 ... yes
10/108 ... yes
24/109 ... yes
24/110 ... yes
3/111 ... yes
24/112 ... yes
10/113 ... yes
16/114 ... yes
21/115 ... yes
16/116 ... yes
3/117 ... yes
9/119 ... yes
23/121 ... yes
23/122 ... yes
10/123 ... yes
27/124 ... yes
26/126 ... yes
30/127 ... yes
3/128 ... yes
24/129 ... yes
3/130 ... yes
3/131 ... yes
3/133 ... yes
24/134 ... yes
6/135 ... yes
23/136 ... yes
25/137 ... yes
3/138 ... yes
9/139 ... yes
3/140 ... yes
3/141 ... yes
21/143 ... yes
30/144 ... yes
3/145 ... yes
24/146 ... yes
24/147 ... yes
21/148 ... yes
24/149 ... yes
10/150 ... yes
24/151 ... yes
27/152 ... yes
27/153 ... yes
23/154 ... yes
23/156 ... yes
3/157 ... yes
32/159 ... yes
10/160 ... yes
21/163 ... yes
16/164 ... yes
21/165 ... yes
30/166 ... yes
23/168 ... yes
3/169 ... yes
25/170 ... yes
24/171 ... yes
14/172 ... yes
24/173 ... yes
10/174 ... yes
3/175 ... yes
3/176 ... yes
10/177 ... yes
21/178 ... yes
3/179 ... yes
24/180 ... yes
24/181 ... yes
24/182 ... yes
10/183 ... yes
3/184 ... yes
24/185 ... yes
21/186 ... yes
30/187 ... yes
3/188 ... yes
3/189 ... yes
14/190 ... yes
24/191 ... yes
3/192 ... yes
24/193 ... yes
3/194 ... yes
21/195 ... yes
21/196 ... yes
38/197 ... yes
38/198 ... yes
34/199 ... yes
21/200 ... yes
10/201 ... yes
25/202 ... yes
10/203 ... yes
14/204 ... yes
38/206 ... yes
38/207 ... yes
23/208 ... yes
23/209 ... yes
23/210 ... yes
21/211 ... yes
40/214 ... yes
40/215 ... yes
40/216 ... yes
40/217 ... yes
40/218 ... yes
23/219 ... yes
24/220 ... yes
24/221 ... yes
3/222 ... yes
24/223 ... yes
24/224 ... yes
24/226 ... yes
23/227 ... yes
21/228 ... yes
24/229 ... yes
21/230 ... yes
16/231 ... yes
23/232 ... yes
3/233 ... yes
24/234 ... yes
42/235 ... yes
42/236 ... yes
23/237 ... yes
3/238 ... yes
3/240 ... yes
24/241 ... yes
21/242 ... yes
21/243 ... yes
16/244 ... yes
21/245 ... yes
30/246 ... yes
24/247 ... yes
21/248 ... yes
23/249 ... yes
3/250 ... yes
10/251 ... yes
23/252 ... yes
24/253 ... yes
24/254 ... yes
23/255 ... yes
21/256 ... yes
23/257 ... yes
24/258 ... yes
24/259 ... yes
21/260 ... yes
21/261 ... yes
24/262 ... yes
21/263 ... yes
25/264 ... yes
25/265 ... yes
10/266 ... yes
25/267 ... yes
21/268 ... yes
3/269 ... yes
6/270 ... yes
3/271 ... yes
3/272 ... yes
10/273 ... yes
10/274 ... yes
3/275 ... yes
21/276 ... yes
21/277 ... yes
21/278 ... yes
10/279 ... yes
21/280 ... yes
24/281 ... yes
10/282 ... yes
10/283 ... yes
10/284 ... yes
10/285 ... yes
10/286 ... yes
10/287 ... yes
23/288 ... yes
21/290 ... yes
21/291 ... yes
10/292 ... yes
47/293 ... yes
35/294 ... yes
49/295 ... yes
47/296 ... yes
3/298 ... yes
24/300 ... yes
24/301 ... yes
47/302 ... yes
23/303 ... yes
3/304 ... yes
24/305 ... yes
16/306 ... yes
316/307 ... yes
316/308 ... yes
24/309 ... yes
10/310 ... yes
16/311 ... yes
21/312 ... yes
10/313 ... yes
38/314 ... yes
21/315 ... yes
21/316 ... yes
10/317 ... yes
10/318 ... yes
10/319 ... yes
3/320 ... yes
24/321 ... yes
3/322 ... yes
10/323 ... yes
10/324 ... yes
10/325 ... yes
Redis version >= 6.0.0? ... yes
Ruby version >= 2.7.2 ? ... yes (2.7.5)
Git user has default SSH configuration? ... yes
Active users: ... 21
Is authorized keys file accessible? ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes

Checking GitLab App ... Finished


Checking GitLab subtasks ... Finished

Possible fixes

This might be the origin for this issue as this addresses the pdf library in 15.5: !99492 (merged)

I can't exclude that our Apache configuration has to be changed, despite it has worked flawlessly for Gitlab 15.4 and older .

Edited by 🤖 GitLab Bot 🤖