fetch: TypeError: NetworkError when attempting to fetch resource - firefox issue
Hi, I have simple function for logout that looks like this
public logoutHandler() {
fetch('/logout', <RequestInit>{
method: 'get',
credentials: 'include'
}).then((response) => {
console.log(document.cookie);
window.location.href = '/login';
});
}
It is workin in chrome but in firefox I get “TypeError: NetworkError when attempting to fetch resource.1 (unknown)”. Client side app is on the same server as backend, I’m using https connection with self-signed cert, could it be the issue?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 23
- Comments: 22 (1 by maintainers)
On chrome, I’ve got “TypeError: Failed to fetch” On firefox, the same “TypeError: NetworkError when attempting to fetch resource” …
Can we reopen this ticket? I’m seeing the same error, but only on Firefox. Also, nothing shows up in the Network tab.
For those who are writing Firefox addon, the solution here helped me, I have to add
"*://localhost/*"topermissionskey inmanifest.json:Chrome just works without the need to add this permission…
Have you check errors like CORS?
@ariden83 did you figure out what was causing the errors? I’m seeing the same issues in isolated cases
Check if you are using http or https on your server. For me, the error was coming online with heroku server because they use https while in local machine I was using http and it was working. After choosing https on Heroku for my endpoints, it also worked
There maybe relational link.
Fetch api not working in firefox addon : firefox 1346447 - Fetch api not working within addon
In our case, the solution was not using the wild card for
Access-Control-Allow-Originon the server side, instead of the wild card, our settings look like this:Having the same issue when I have
network.http.referer.XOriginPolicyset to1(“send a referrer only when the base domains are the same”). Is that supposed to happen? I’m quite sure the base domain oflocalhostmatches the base domain of itself 😃I’m seeing the same error,except chrome
I managed to solve the problem by monitoring the headers returned by github used on the demo page.
Since I’m using a python webserver, they look something like this:
Hope it helps.
Firefox contains a native fetch implementation and does not use this polyfill code. You can use the Network tab in Firefox’s web console to debug the request and response.