diff --git a/functions/api/contact.ts b/functions/api/contact.ts index 243cfc6..66626e2 100644 --- a/functions/api/contact.ts +++ b/functions/api/contact.ts @@ -122,8 +122,9 @@ const handlePost: PagesFunction = async ({ request, env }) => { replyTo: [{ address: email }], }; + const apiBase = endpoint.replace(/\/$/, ""); const response = await fetch( - `${endpoint.replace(/\\/$/, "")}/emails:send?api-version=2023-03-31`, + apiBase + "/emails:send?api-version=2023-03-31", { method: "POST", headers: { @@ -150,10 +151,7 @@ const handlePost: PagesFunction = async ({ request, env }) => { export const onRequest: PagesFunction = async (context) => { if (context.request.method !== "POST") { - return jsonResponse( - { ok: false, error: "Method not allowed." }, - 405, - ); + return jsonResponse({ ok: false, error: "Method not allowed." }, 405); } return handlePost(context); }; diff --git a/wrangler.jsonc b/wrangler.jsonc index 430f0ec..9f15edd 100644 --- a/wrangler.jsonc +++ b/wrangler.jsonc @@ -1,14 +1,14 @@ { - "name": "rda-2026", - "main": "src/worker.ts", - "compatibility_date": "2025-12-21", - "assets": { - "directory": "./dist/public", - "binding": "ASSETS", - "not_found_handling": "single-page-application", - }, - "vars": { - "CONTACT_FROM_EMAIL": "info@highlandgrouprda.org.uk", - "CONTACT_TO_EMAIL": "info@highlandgrouprda.org.uk", - }, + "name": "rda-2026", + "main": "src/worker.ts", + "compatibility_date": "2025-12-21", + "assets": { + "directory": "./dist/public", + "binding": "ASSETS", + "not_found_handling": "single-page-application" + }, + "vars": { + "CONTACT_FROM_EMAIL": "info@highlandgrouprda.org.uk", + "CONTACT_TO_EMAIL": "info@highlandgrouprda.org.uk" + } }