Skip to content

Commit

Permalink
Added proxy for authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
macedonga committed Oct 26, 2024
1 parent d11d718 commit 2a3620c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
11 changes: 10 additions & 1 deletion cron/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ const requestAuthenticated = async (endpoint, data, idx = 0) => {
"bereal-signature": SIGNATURE,
"bereal-device-id": "937v3jb942b0h6u9",
"bereal-timezone": "Europe/Paris",
}
},
"proxy": process.env.USE_PROXY ? {
"protocol": "http",
"host": process.env.PROXY_HOST,
"port": process.env.PROXY_PORT,
"auth": {
"username": process.env.PROXY_USER,
"password": process.env.PROXY_PASS
}
} : null
}
);

Expand Down
12 changes: 11 additions & 1 deletion pages/api/vonage/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ export default async function handler(req, res) {
"bereal-signature": (await fetchSignature()),
"bereal-device-id": "937v3jb942b0h6u9",
"bereal-timezone": "Europe/Paris",
}
},
"proxy": process.env.USE_PROXY ? {
"protocol": "http",
"host": process.env.PROXY_HOST,
"port": process.env.PROXY_PORT,
"auth": {
"username": process.env.PROXY_USER,
"password": process.env.PROXY_PASS
}
} : null
}
);

Expand All @@ -48,6 +57,7 @@ export default async function handler(req, res) {
});
return;
} catch (error) {
console.log(error);
return res.status(500).json({ error: "Internal server error", success: false });
}
};
12 changes: 11 additions & 1 deletion pages/api/vonage/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ export default async function handler(req, res) {
"bereal-signature": (await fetchSignature()),
"bereal-device-id": "937v3jb942b0h6u9",
"bereal-timezone": "Europe/Paris",
}
},
"proxy": process.env.USE_PROXY ? {
"protocol": "http",
"host": process.env.PROXY_HOST,
"port": process.env.PROXY_PORT,
"auth": {
"username": process.env.PROXY_USER,
"password": process.env.PROXY_PASS
}
} : null
}
);

Expand Down Expand Up @@ -61,6 +70,7 @@ export default async function handler(req, res) {
success: true,
});
} catch (e) {
console.log(e)
const errorCodes = {
"INVALID_CODE": "The code is incorrect.",
"SESSION_EXPIRED": "The SMS code has expired. Please re-send the verification code to try again.",
Expand Down
11 changes: 10 additions & 1 deletion utils/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ const requestAuthenticated = async (endpoint, request, response, method = "get",
"bereal-signature": SIGNATURE,
"bereal-device-id": "937v3jb942b0h6u9",
"bereal-timezone": "Europe/Paris",
}
},
"proxy": process.env.USE_PROXY ? {
"protocol": "http",
"host": process.env.PROXY_HOST,
"port": process.env.PROXY_PORT,
"auth": {
"username": process.env.PROXY_USER,
"password": process.env.PROXY_PASS
}
} : null
}
);

Expand Down

0 comments on commit 2a3620c

Please sign in to comment.