You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
554 B
12 lines
554 B
import { getRequestIP } from "h3";
|
|
import { createCaptchaChallenge } from "#server/service/captcha/challenge";
|
|
import { assertUnderRateLimit } from "#server/utils/simple-rate-limit";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
setResponseHeader(event, "cache-control", "no-store");
|
|
const ip = getRequestIP(event, { xForwardedFor: true }) ?? "unknown";
|
|
assertUnderRateLimit(`auth-captcha:${ip}`, 60, 60_000);
|
|
|
|
const { captchaId, imageSvg } = createCaptchaChallenge();
|
|
return R.success({ captchaId, imageSvg });
|
|
});
|
|
|