Fix worker endpoint URL regex
This commit is contained in:
parent
a294c8593b
commit
c3cc8cfb1c
1 changed files with 6 additions and 5 deletions
|
|
@ -37,12 +37,13 @@ const handleContact = async (request: Request, env: Env) => {
|
|||
const name = readFormField(formData.get("name"));
|
||||
const email = readFormField(formData.get("email"));
|
||||
const message = readFormField(formData.get("message"));
|
||||
const turnstileToken = readFormField(
|
||||
formData.get("cf-turnstile-response"),
|
||||
);
|
||||
const turnstileToken = readFormField(formData.get("cf-turnstile-response"));
|
||||
|
||||
if (!name || !email || !message) {
|
||||
return jsonResponse({ ok: false, error: "Missing required fields." }, 400);
|
||||
return jsonResponse(
|
||||
{ ok: false, error: "Missing required fields." },
|
||||
400,
|
||||
);
|
||||
}
|
||||
|
||||
if (!env.TURNSTILE_SECRET_KEY) {
|
||||
|
|
@ -122,7 +123,7 @@ const handleContact = async (request: Request, env: Env) => {
|
|||
};
|
||||
|
||||
const response = await fetch(
|
||||
`${endpoint.replace(/\\/$/, "")}/emails:send?api-version=2023-03-31`,
|
||||
`${endpoint.replace(/\/$/, "")}/emails:send?api-version=2023-03-31`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue