OS type and version: Ubuntu 20.04.2
Webmin version: 1.973
Virtualmin version: 6.16
I’m trying to run a simple list domains command on my Virtualmin server via the Remote API using JavaScript fetch api but I keep getting a ERR_ABORTED 401 (Unauthorized) response.
I’m sending the GET request https://example.com:10000/virtual-server/remote.cgi?program=list-domains&json=1
with mode set to no-cors
and Access-Control-Allow-Origin set to *
.
I have also added basic access authentication containing base64 encoded username and password in the request header as follows:
headers: {
'Authorization': 'Basic ' + btoa('root:some-password')
}
Accessing the url ‘https://example.com:10000/virtual-server/remote.cgi?program=list-domains&json=1’
directly from the browser works fine and the JSON data is served after providing the username and password. I am sure the JS code that I use for fetching the data is working fine too since if I use the same code to request data from other APIs that don’t require authentication, it works fine.
How do I fix the (most probably cors-related) authorization issue?