Question
how to test my servlet via Javascript in localhost?
So in postman, I am sending using this header

and this is working fine. (YW string is admin:admin encoded using base64).
I'm trying to do the same in javascript, but I keep on getting a 403.
headers.append('Content-Type', 'application/json');
if (window.location.host.indexOf('localhost') != -1) {
headers.append('Authorization', 'Basic YWRtaW46YWRtaW4=');
}
const response = await fetch(myUrl,
{
method: 'POST',
headers: headers,
body: payload
}
);
Any ideas on how it can be done? Thanks