This commit is contained in:
parent
c96525e1fc
commit
4656df7fca
@ -6,7 +6,7 @@ export async function getReCaptchaSiteKey() {
|
||||
return process.env.RECAPTCHA_SITE_KEY;
|
||||
}
|
||||
|
||||
const RECAPTCHA_SECRET_KEY = process.env.RECAPTCHA_SECRET_KEY;
|
||||
const RECAPTCHA_SERVER_KEY = process.env.RECAPTCHA_SERVER_KEY;
|
||||
|
||||
export type SubmitContactReturn = { error: string } | { success: true };
|
||||
|
||||
@ -14,9 +14,9 @@ export default async function SubmitContact(
|
||||
prevState: unknown,
|
||||
data: FormData
|
||||
): Promise<SubmitContactReturn> {
|
||||
if (!RECAPTCHA_SECRET_KEY) {
|
||||
if (!RECAPTCHA_SERVER_KEY) {
|
||||
console.error(
|
||||
"RECAPTCHA_SECRET_KEY is not set. Please check your environment variables."
|
||||
"RECAPTCHA_SERVER_KEY is not set. Please check your environment variables."
|
||||
);
|
||||
throw new Error("Server error: RECAPTCHA not configure correctly.");
|
||||
}
|
||||
@ -42,7 +42,7 @@ export default async function SubmitContact(
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: `secret=${RECAPTCHA_SECRET_KEY}&response=${recaptcha}`,
|
||||
body: `secret=${RECAPTCHA_SERVER_KEY}&response=${recaptcha}`,
|
||||
}
|
||||
);
|
||||
const recaptchaData = await recaptchaResponse.json();
|
||||
|
Loading…
x
Reference in New Issue
Block a user