I am creating an API that post to 3rd party API . I need to fetch CSRF-Token and cookies, in order to post to that API.
In the fetchCred I fetch CSRF-Token and cookies using getResponseHeader("set-cookie") and getResponseHeader("x-csrf-token") correctly.
Then I want to use these values in the Create.js to post data.
However, I can't set-cookies manually because JavaScript cannot set cookie headers, since it returns 400 Refused to set unsafe header "Cookie"
Is there a workaround on how to pass the fetched cookies in the post method cookie header?
fetchCred.js
request.open("GET", url, true);
request.setRequestHeader("Authorization", "Basic xxxxx");
request.setRequestHeader("X-CSRF-Token", "fetch");
create.js
request.open("POST", url, true);
request.setRequestHeader("Authorization", "Basic xxxxx");
request.setRequestHeader("X-CSRF-Token", token);
request.setRequestHeader("Cookie", cookie);
I would really appreciate your help