Pages CORS issue

Summary

Search function on MkDocs static site hosted on omnibus Gitlab pages breaks because of CORS

Steps to reproduce

  • Gitlab self-hosted at code.domain.com

  • Documentation project in Group: Docs, Project: Internal. The project is Private.

  • Doc site is built with MkDocs and available at https://docs.domain.net/internal

  • we use wildcard domain for Gitlab pages

  • gitlab_pages['access_control'] = true in gitlab.rb

  • all working well

  • The site has a search function. The search index is stored in https://docs.domain.net/internal/search/search_index.json. That file is loaded dynamically with javascript, ie it's not linked to from page but instead only loaded if one clicks in the Search input box.

What is the current bug behavior?

The search javascript on the page cannot load the search index file because of CORS.

Maybe the problem is not actually CORS but instead that auth is requested to the wrong domain. The Gitlab instance is at code.domain.com. The pages are at docs.domain.net. The auth request is made to projects.domain.net

Because there's a wildcard at DNS, projects.domain.net resolves to the same machine as code.domain.com and docs.domain.net. But is this the right domain to ask auth to? shouldn't it be code.domain.com?

What is the expected correct behavior?

Search function works normally, json should be accessed from javascript, even if authentication is needed. Am I missing some configuration here?

Relevant logs and/or screenshots

Access to fetch at 'https://projects.domain.net/auth?domain=https://docs.domain.net&state=9mkMjxxxxxxxxxcmcCbQ==' (redirected from 'https://docs.domain.net/docs_internal/search/search_index.json') from origin 'https://docs.domain.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

sudo gitlab-rake gitlab:env:info == >

System information System: Debian 9.11 Current User: git Using RVM: no Ruby Version: 2.6.3p62 Gem Version: 2.7.9 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 3.2.12 Git Version: 2.22.0 Sidekiq Version:5.2.7 Go Version: unknown

GitLab information Version: 12.4.1 Revision: 4281915cfeb Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 10.9 URL: https://code.domain.com HTTP Clone URL: https://code.domain.com/some-group/some-project.git SSH Clone URL: git@code.domain.com:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers:

GitLab Shell Version: 10.2.0 Repository storage paths:

  • default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git

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 >= 10.2.0 ? ... OK (10.2.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 ... 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: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes 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 Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/3 ... yes 2/4 ... yes 2/5 ... yes 2/6 ... yes 2/7 ... yes 9/8 ... yes 2/9 ... yes 2/10 ... yes 2/11 ... yes 2/12 ... yes 2/13 ... yes 2/14 ... yes 2/15 ... yes 2/16 ... yes 2/17 ... yes 2/18 ... yes 2/19 ... yes 2/20 ... yes 2/21 ... yes 2/22 ... yes 2/23 ... yes 2/24 ... yes 2/25 ... yes 2/26 ... yes 2/27 ... yes 2/28 ... yes 2/29 ... yes 2/30 ... yes 2/31 ... yes 2/32 ... yes 2/33 ... yes 2/34 ... yes 2/35 ... yes 2/36 ... yes 2/37 ... yes 2/38 ... yes 2/40 ... yes 2/41 ... yes 2/42 ... yes 2/43 ... yes 2/44 ... yes 2/46 ... yes 7/47 ... yes 2/48 ... yes 2/49 ... yes 2/50 ... yes 2/51 ... yes 2/52 ... yes 2/53 ... yes 2/54 ... yes 9/56 ... yes 2/57 ... yes 10/58 ... yes 10/59 ... yes 3/60 ... yes 11/61 ... yes 2/62 ... yes 10/63 ... yes 10/65 ... yes 10/66 ... yes 2/68 ... yes 13/69 ... yes 13/70 ... yes 13/72 ... yes 13/73 ... yes 13/74 ... yes 13/75 ... yes 13/76 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.3) Git version >= 2.22.0 ? ... yes (2.22.0) Git user has default SSH configuration? ... yes Active users: ... 3 Is authorized keys file accessible? ... yes

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

Edited Nov 01, 2019 by Yannick Gaultier
Assignee Loading
Time tracking Loading