Turns out captchas can be larger than 1KB. And turns out people use websites from inside Instagram.

This commit is contained in:
Felipe Cotti 2024-10-27 17:01:32 -03:00
parent f0fcb9f916
commit 3dc8f16de0
2 changed files with 16 additions and 15 deletions

View file

@ -17,6 +17,6 @@ public record InsertMessageRequestDto
[JsonPropertyName("captchaResponse")]
[Required(ErrorMessage = "The captcha challenge response is required")]
[StringLength(1024)]
[StringLength(2048)]
public string CaptchaResponse { get; init; }
}

View file

@ -133,22 +133,23 @@ document
captchaResponse,
};
const response = await fetch(this.action, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
const dataJson = JSON.stringify(data);
if (response.status >= 200 && response.status <= 299) {
alert("Note added successfully!");
this.reset(); // Clear the form fields
} else {
const problem = await response.json();
alert(problem);
const xhr = new XMLHttpRequest();
xhr.open("POST", this.action, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader('Content-Length', dataJson.length);
xhr.send(dataJson);
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status <= 299) {
alert("Message sent successfully.");
this.reset(); // Clear the form fields
} else {
alert("An error " + xhr.status + "occurred: " + xhr.responseText);
}
}
});
});
</script>
</body>
</html>