You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see ClientRequest being return from net.request, but I don't see how I would get a ClientRequest with net.fetch. It seems the only way for redirect: 'manual' to work with net.fetch, the returned Response would have to hold the redirect status. This is how Node.js' fetch implements redirect: 'manual'.
I'm trying use net.fetch as a drop-in for the global fetch from Node.js because net.fetch comes with proxy support and loads certificates from the OS.
@MarshallOfSound this might be a bug in our net.fetch implementation. The spec mentions if mode is not navigate then an opaqueResponse should be provided. We are missing the handling of redirect event in the implementation today.
For browsers opaque responses are needed for preventing xss attacks https://fetch.spec.whatwg.org/#atomic-http-redirect-handling. In Electron, users already can use Node.js fetch in these process to get those responses, so if we were to align net.fetch behavior we are not increasing the risk any higher. Also, the api is meant to offer easy migration for users from Node.js fetch to use chromium network stack, so aligning their behaviors would be better in this case.
this also prevents (AFAIK) conditionally but completely intercepting http/s protocol by preventing the browser from following redirects.
Appologies for the dumb question but Is anyone aware of an alternative solution to implement this currently using net.request (the issue here being a complete reproduction of the GlobalRequest to ClientRequest to listen for the 'redirect' event)?
protocol.handle('http', (request) => {
if (shouldOverride) {
// do my own thing
} else {
// if I want to leverage Chromium for Kerberos SSO and other benefits but the renderer must follow redirects so orgin is correct on future requests
return net.fetch(request, {
bypassCustomProtocolHandlers: true,
redirect: 'manual'
});
}
}
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.
Activity
MarshallOfSound commentedon Sep 13, 2024
This is working as documented, the request is cancelled if you don't call
followRedirectinside theredirectevent when redirect mode ismanual.Ref: https://www.electronjs.org/docs/latest/api/client-request#event-redirect
chrmarti commentedon Sep 13, 2024
I see
ClientRequestbeing return fromnet.request, but I don't see how I would get aClientRequestwithnet.fetch. It seems the only way forredirect: 'manual'to work withnet.fetch, the returnedResponsewould have to hold the redirect status. This is how Node.js'fetchimplementsredirect: 'manual'.I'm trying use
net.fetchas a drop-in for the globalfetchfrom Node.js becausenet.fetchcomes with proxy support and loads certificates from the OS.deepak1556 commentedon Sep 14, 2024
@MarshallOfSound this might be a bug in our
net.fetchimplementation. The spec mentions ifmodeis notnavigatethen anopaqueResponseshould be provided. We are missing the handling ofredirectevent in the implementation today.Node.js fetch response also seems different from the spec, ref wpt tests https://github.com/web-platform-tests/wpt/blob/master/fetch/api/redirect/redirect-mode.any.js
deepak1556 commentedon Sep 16, 2024
Okay Node.js implementation was initially following the spec but it was later changed per nodejs/undici#1193.
What should be the behavior we match in our
net.FetchAPI for this case ?deepak1556 commentedon Sep 16, 2024
For browsers opaque responses are needed for preventing xss attacks https://fetch.spec.whatwg.org/#atomic-http-redirect-handling. In Electron, users already can use Node.js fetch in these process to get those responses, so if we were to align net.fetch behavior we are not increasing the risk any higher. Also, the api is meant to offer easy migration for users from Node.js fetch to use chromium network stack, so aligning their behaviors would be better in this case.
jaouadeljadiri commentedon Sep 24, 2024
#43774
jhudson8 commentedon Oct 8, 2024
this also prevents (AFAIK) conditionally but completely intercepting http/s protocol by preventing the browser from following redirects.
Appologies for the dumb question but Is anyone aware of an alternative solution to implement this currently using net.request (the issue here being a complete reproduction of the GlobalRequest to ClientRequest to listen for the 'redirect' event)?
electron-issue-triage commentedon Feb 18, 2025
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
7 remaining items
namonakimono commentedon Mar 27, 2025
Same issue +1
electron-issue-triage commentedon Jun 26, 2025
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
xiaoshuangLi commentedon Jun 26, 2025
Same issue +1
jhudson8 commentedon Aug 29, 2025
Has there been any movement on this or any idea of an ETA?
Once complete, how would we get a reference to cancel a redirect with net.fetch? I'm looking to NOT follow any redirects.
Thanks so much.
electron-issue-triage commentedon Nov 28, 2025
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
electron-issue-triage commentedon Feb 27, 2026
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
electron-issue-triage commentedon Mar 29, 2026
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.
fix(subscriptions): intercept redirect hops in the kernel-proxy fallb…