Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: use node.js fetch instead of net.fetch

Abdullah Atta8b5babd5f889
diff --git a/apps/desktop/src/utils/protocol.ts b/apps/desktop/src/utils/protocol.ts
index da3d46061..200bc72f7 100644
--- a/apps/desktop/src/utils/protocol.ts
+++ b/apps/desktop/src/utils/protocol.ts
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { protocol, net } from "electron";
+import { protocol } from "electron";
import { isDevelopment } from "./index";
import { createReadStream } from "fs";
import { extname, normalize } from "path";
@@ -62,8 +62,25 @@ function registerProtocol() {
headers: { "Content-Type": extensionToMimeType[fileExtension] }
});
} else {
- return net.fetch(request, {
- bypassCustomProtocolHandlers: true
+ if (request.headers.has("X-Content-Length")) {
+ request.headers.set(
+ "Content-Length",
+ request.headers.get("X-Content-Length") || "0"
+ );
+ request.headers.delete("X-Content-Length");
+ }
+ const headers = Object.fromEntries(request.headers.entries());
+
+ return await fetch(request.url, {
+ signal: request.signal,
+ mode: request.mode,
+ headers,
+ method: request.method,
+ body: request.body,
+ credentials: request.credentials,
+ referrer: (request as any).referrer,
+ duplex: "half",
+ redirect: "manual"
});
}
});