Estoy usando Axios en un script de nodo mjs. Estoy accediendo a un servidor que usa autenticación http básica. en el navegador, si golpeo
http://user:pass@192.168.254.4/api/endpoint1funciona y me da los datos solicitados, pero cuando uso la misma URL en el método Axios.get, falla.
Unauthorized This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (eg, bad password), or your browser doesn't understand how to give the credentials required.lo mismo en cartero también (tampoco funciona en cartero).
¿Me estoy perdiendo de algo?
Aquí está el código:
var session_url = 'http://api_address/api/session_endpoint'; var username = 'user'; var password = 'password'; var credentials = btoa(username + ':' + password); var basicAuth = 'Basic ' + credentials; axios.post(session_url, { headers: { 'Authorization': + basicAuth } })