Added /api/ prefix to CAPTCHA API URL.

This commit is contained in:
Alexander Andreev 2022-10-21 02:10:43 +04:00
parent c1b056e22b
commit 7026ee68c1
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -10,10 +10,10 @@ function getColorScheme() {
}
async function getNewCaptcha() {
const id = await fetch("/captcha/").then(r => r.text());
const id = await fetch("/api/captcha/", { method: "POST"}).then(r => r.text());
g_current_captcha_id = id;
captcha_hidden_field.value = id;
setTimeout(() => { captcha_img.src = `/captcha/${id}/image?style=${getColorScheme()}` }, 600);
setTimeout(() => { captcha_img.src = `/api/captcha/${id}/image?style=${getColorScheme()}` }, 600);
g_captcha_timeout_remain = g_captcha_timeout_seconds;
}
@ -33,13 +33,13 @@ captcha_refresh.addEventListener("click", async e => {
captcha_refresh.disabled = true;
setTimeout(async () => {
captcha_refresh.disabled = false;
await fetch(`/captcha/${g_current_captcha_id}?remove`); }, 3000);
await fetch(`/api/captcha/${g_current_captcha_id}?remove`); }, 3000);
document.getElementsByName("captcha_answer")[0].value = "";
await getNewCaptcha();
});
// Remove unused CAPTCHA on a server.
window.addEventListener("unload", () => fetch(`/captcha/${g_current_captcha_id}?remove`));
window.addEventListener("unload", () => fetch(`/api/captcha/${g_current_captcha_id}?remove`));
setInterval(async () => {
captcha_remain.innerText = --g_captcha_timeout_remain;