Maybe I’m missing something, since I’m new to using browser extensions. From an extension a request is made to a proxy, the proxy obtains the response from the final server that responds with the entire HTML document. In the extension I receive everything, including the html and headers. What do I have to do now with that html? what I want is for the new updated cookies to be installed in the browser.
chrome.runtime.onMessage.addListener( async function (request, sender, sendResponse) {
console.log("received message:", request.data)//-------------------
if (request.action === "initAction") {
try {
// Make a GET request to the proxy server
const response = await fetch('http://------/proxy/service1', {
method: 'GET',
// credentials: 'include', // Should I include the credentials?
headers: {
'Content-Type': 'application/json'
}
});
if (response.ok) {
console.log(response.type);//------response ok, html document
//***********What should I do with the answer?
//***********I tried to redirect to a new tab but the new cookies are not added to the browser
chrome.tabs.create({ url: '---------' }); // Redirect user
} else {
console.error('Error proxy:', response.statusText);
}
} catch (error) {
sendResponse({ mensaje: "Error" });
}
return true;
}
});
What is the reason? The company’s login credentials are hosted in the proxy. Then, workers only need to refresh the page to receive the cookies and log in.
I tried to redirect to a new tab but the new cookies are not added to the.