Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

fix INVALID_PROTOCOL when saving http website

Jan van Brügge327826d760e5
diff --git a/apps/web/lib/shared/fetchTitleAndHeaders.ts b/apps/web/lib/shared/fetchTitleAndHeaders.ts
index 8a7bcefc..a95f00a9 100644
--- a/apps/web/lib/shared/fetchTitleAndHeaders.ts
+++ b/apps/web/lib/shared/fetchTitleAndHeaders.ts
@@ -1,5 +1,6 @@
import fetch from "node-fetch";
import https from "https";
+import http from "http";
import { HttpsProxyAgent } from "https-proxy-agent";
import { SocksProxyAgent } from "socks-proxy-agent";
@@ -8,10 +9,12 @@ export default async function fetchTitleAndHeaders(url: string) {
return { title: "", headers: null };
try {
- const httpsAgent = new https.Agent({
- rejectUnauthorized:
- process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
- });
+ const httpsAgent = url?.startsWith("http://")
+ ? new http.Agent({})
+ : new https.Agent({
+ rejectUnauthorized:
+ process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
+ });
// fetchOpts allows a proxy to be defined
let fetchOpts = {
diff --git a/apps/worker/lib/fetchHeaders.ts b/apps/worker/lib/fetchHeaders.ts
index 23416dc8..1f5f8563 100644
--- a/apps/worker/lib/fetchHeaders.ts
+++ b/apps/worker/lib/fetchHeaders.ts
@@ -1,5 +1,6 @@
import fetch from "node-fetch";
import https from "https";
+import http from "http";
import { HttpsProxyAgent } from 'https-proxy-agent';
import { SocksProxyAgent } from "socks-proxy-agent";
@@ -7,10 +8,12 @@ export default async function fetchHeaders(url: string) {
if (process.env.IGNORE_URL_SIZE_LIMIT === "true") return null;
try {
- const httpsAgent = new https.Agent({
- rejectUnauthorized:
- process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
- });
+ const httpsAgent = url.startsWith("http://")
+ ? new http.Agent({})
+ : new https.Agent({
+ rejectUnauthorized:
+ process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
+ });
let fetchOpts = {
method: "HEAD",