AH01614: client used wrong authentication scheme: /api/users/admin/check

Hi, I want to restrict the acess to portainer with apache basic authentication, but I’m getting the error:
“AH01614: client used wrong authentication scheme: /api/users/admin/check”
This error only occurs with portainer docker container. My vhost config is below:

<VirtualHost *:80>
ServerName port.mydomain.com
CustomLog logs/portainer_access.log combined
ErrorLog logs/portainer_error.log
Alias "/.well-known" /usr/local/apache2/htdocs/portainer/letsencrypt/.well-known
<Directory /usr/local/apache2/htdocs/portainer/letsencrypt/.well-known> 
Require all granted
</Directory>
ProxyPass /.well-known/ !

RewriteEngine  on
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>

<VirtualHost *:443>
ServerName port.mydomain.com
SetEnvIf Request_URI "^/.well-known" accessgranted=1
CustomLog logs/portainer_access.log combined
ErrorLog logs/portainer_error.log

Alias "/.well-known" /usr/local/apache2/htdocs/portainer/letsencrypt/.well-known
<Directory /usr/local/apache2/htdocs/portainer/letsencrypt/.well-known> 
Require all granted
</Directory>
ProxyPass /.well-known/ !
<LocationMatch "^/">
  AuthType Basic
  AuthName "Please provide username and password"
  AuthBasicProvider file
  AuthUserFile "/usr/local/apache2/htpasswd"
  <RequireAny>
   Require env accessgranted
   Require valid-user
  </RequireAny>
</LocationMatch>
RequestHeader set X-Forwarded-Proto "https"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:9000/
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/port.mydomain.com/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/port.mydomain.com/chain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/port.mydomain.com/privkey.pem

</VirtualHost>

We have not tested Portainer with apache so I cannot say what is the issue, although we do have this issue open on our repository that may be of some help?