Cloning a git repo over https through ngrok

  Kiến thức lập trình

My application clones git repos over https (ssh is not an option) using basic authentication like this:

git clone https://oauth2:[email protected]/acme/repo

I am now trying to clone a repo that lives in a private network exposed through an ngrok proxy. I started the ngrok agent like this:

ngrok http

Then I attempted the clone

git clone https://oauth2:TOKEN_VALUE@NGROK_DOMAIN/acme/repo

The call returns an authentication error

Cloning into ‘repo’…

remote: Repository not found.

fatal: Authentication failed for https://NGROK_DOMAIN/acme/repo/

In the ngrok dashboard, I see one request

GET /acme/repo/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/2.39.3
Accept: */*
Accept-Encoding: deflate, gzip
Git-Protocol: version=2
Pragma: no-cache
X-Forwarded-For: <my IP address>
X-Forwarded-Host: NGROK_DOMAIN
X-Forwarded-Proto: https

Why isn’t clone working? At first I thought the basic auth creds are not being passed on. However if I try to clone without passing the creds, like this:

git clone https://NGROK_DOMAIN/acme/repo

Then I get a different error message that does not mention authentication, but does mention!

Cloning into ‘repo’…

remote: Repository not found.

fatal: repository not found

How can I execute a git clone over https through an Ngrok proxy?