Composer Package Registry returns 404 on Composer API request

Summary

It's not possible for Composer to authentication against Package Registry.

Steps to reproduce

Follow this documentation: https://gitlab.com/help/user/packages/composer_repository/index.md#enabling-the-composer-repository

What is the current bug behavior?

Composer is not possible to use http-basic authentication against gitlab.com. gitlab.com returns 404 no matter if token is correct or incorrect.

What is the expected correct behavior?

gitlab.com should ask for http-basic authentication and Composer should authenticate with given http-basic in auth.json.

Relevant logs and/or screenshots

[Composer\Downloader\TransportException]
  The "https://gitlab.com/api/v4/group/8473041/-/packages/composer/packages.json" file could not be downloaded (HTTP/1.1 404 Not Found)

Output of checks

This bug happens on GitLab.com in combination of Composer 1.10.9 and prior.