Fix dynamic default locale routing
This commit is contained in:
@@ -5,7 +5,7 @@ import { isRedirectError } from "next/dist/client/components/redirect-error";
|
||||
import { z } from "zod";
|
||||
|
||||
import { enforceContactRateLimit, verifyTurnstileToken } from "@/lib/contact-guard";
|
||||
import { getContactProtectionSettings } from "@/lib/app-config";
|
||||
import { getContactProtectionSettings, getSiteSettings } from "@/lib/app-config";
|
||||
import { getLocalizedPath, resolveLocale } from "@/lib/locale";
|
||||
import { sendContactMessage } from "@/lib/mail";
|
||||
|
||||
@@ -60,7 +60,8 @@ function getStringValue(formData: FormData, key: string) {
|
||||
|
||||
export async function submitContactFormAction(formData: FormData) {
|
||||
const locale = resolveLocale(String(formData.get("locale") ?? ""));
|
||||
const contactPath = getLocalizedPath(locale, "/contact");
|
||||
const siteSettings = await getSiteSettings();
|
||||
const contactPath = getLocalizedPath(locale, "/contact", siteSettings.defaultLocale);
|
||||
|
||||
try {
|
||||
const protectionSettings = await getContactProtectionSettings();
|
||||
@@ -86,7 +87,13 @@ export async function submitContactFormAction(formData: FormData) {
|
||||
message: values.message,
|
||||
});
|
||||
|
||||
redirect(withMessage(getLocalizedPath(locale, "/success"), "success", contactSuccessMessages[locale]));
|
||||
redirect(
|
||||
withMessage(
|
||||
getLocalizedPath(locale, "/success", siteSettings.defaultLocale),
|
||||
"success",
|
||||
contactSuccessMessages[locale],
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user