So I was having the same problem as this: No 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST API
And I followed the solution, and now I get a response from the server I am trying to fetch from, which is the html page. Great! But, I have a problem. I need to request the server in order to get a session id cookie, which should be in the response header, but when I log the response headers, there are none there. This is my code:
const proxyurl = "https://cors-anywhere.herokuapp.com/";
const url = "(my url)";
function requestAuth(username, password) {
fetch(proxyurl + url)
.then((response) => {
console.log(response.headers);
return response.text();
})
.then((contents) => console.log(contents))
.catch(() =>
console.log("Can’t access " + url + " response. Blocked by browser?")
);
}
And yes, I know this isn't a POST request, the way this website works is very weird, you have to make a get request to get the session then you can make a post to auth with the session cookie.
How can I: #1: Get the response headers from the url through the proxy and #2: send a response with some http-only cookies through the proxy?
EDIT:
Here is the output for the console.log(response.headers)