Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: automatically add json content-type to webhook forms (#3889)

Bogdan Chadkina22cbd4573de
diff --git a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
index 3ca140eb53..dfbcf6458e 100644
--- a/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
+++ b/fixtures/webstudio-cloudflare-template/app/routes/[another-page]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
index 320465a628..d89665fc9d 100644
--- a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
index 361c2360f2..55291b6514 100644
--- a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
index 32cf0e487f..65ef6e449d 100644
--- a/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-custom-template/app/routes/_index.tsx b/fixtures/webstudio-custom-template/app/routes/_index.tsx
index 320465a628..d89665fc9d 100644
--- a/fixtures/webstudio-custom-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/_index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx
index 3ca140eb53..dfbcf6458e 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/[another-page]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
index 320465a628..d89665fc9d 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx
index 3ca140eb53..dfbcf6458e 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/[another-page]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
index 320465a628..d89665fc9d 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
index 9417efc238..4b68bae255 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
index 3e1c22e366..de029ac8c6 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
index 86b580d2d8..609c4c131e 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
index 7ae1ca55b1..b308ee3182 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
index a425663a80..99e1f93eff 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
index ec533a0ea6..5316bee007 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
index 320465a628..d89665fc9d 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");
diff --git a/packages/cli/templates/defaults/app/route-templates/html.tsx b/packages/cli/templates/defaults/app/route-templates/html.tsx
index 71d63bc7c8..e118f47970 100644
--- a/packages/cli/templates/defaults/app/route-templates/html.tsx
+++ b/packages/cli/templates/defaults/app/route-templates/html.tsx
@@ -286,10 +286,11 @@ export const action = async ({
formData.delete(formBotFieldName);
if (resource) {
- resource = {
- ...resource,
- body: Object.fromEntries(formData),
- };
+ resource.headers.push({
+ name: "Content-Type",
+ value: "application/json",
+ });
+ resource.body = Object.fromEntries(formData);
} else {
if (contactEmail === undefined) {
throw new Error("Contact email not found");