Handle contact route with trailing slash

This commit is contained in:
Calum Muir 2025-12-22 13:18:03 +00:00
parent 5fc57a36c9
commit 787256b5c6

View file

@ -151,7 +151,10 @@ const handleContact = async (request: Request, env: Env) => {
export default { export default {
async fetch(request: Request, env: Env): Promise<Response> { async fetch(request: Request, env: Env): Promise<Response> {
const url = new URL(request.url); const url = new URL(request.url);
if (url.pathname === "/api/contact") { if (
url.pathname === "/api/contact" ||
url.pathname === "/api/contact/"
) {
if (request.method !== "POST") { if (request.method !== "POST") {
return jsonResponse( return jsonResponse(
{ ok: false, error: "Method not allowed." }, { ok: false, error: "Method not allowed." },