- Background: I am building a chrome extension that sends a simple http request and should be able to work with ssl client authentication.
- Goal: Send a fetch request to a site with ssl client authentication without user having to open the site first.
- What happens so far:
- The request is only successful after i open the site manually.
- Attempted using
credentials: 'include'
as suggested here - didn't solve the issue. - Im getting
TypeError: failed to fetch
- Fetch API docs @ Mozilla don't seem to mention this (here and here)
fetch is sent as follows:
fetch(url)
.then(response => {
if(!response.ok){
throw Error("Http request failed");
}else{
return response
}
})
.then(response => response.text())
.then(validate => validate.replace(/\D/g,''))
.then(count => {
chrome.action.setBadgeText({text: count});
if(callback){
callback();
}
})
.catch(error => {
console.log(error)
if(callback){
callback();
}
});
I would be very grateful if you could guide me on what might be the issue.
As this is was not resolve for a couple of years or so, i opened a bug at the chromium bug tracker
chrome.tabs.create({ url: 'https://YourUnsecureAPIServer' })
. After this my fetch call worked inside my Chrome Extensions' background script. Chrome will probably prompt you about visiting an insecure website, if you haven't manually approved it previously. There may be a more elegant way but this works for my private context (the extension is internal use only). – Chanty