From ec585e443924a79107d42047d6c0fc48506c2980 Mon Sep 17 00:00:00 2001 From: Jonas Brunvoll Larsson Date: Thu, 16 Jan 2025 13:51:22 +0100 Subject: [PATCH] Define body size limit in all contact form endpoints as spread of imported config is not supported by NEXT. --- src/pages/api/contact/contact-api-config.ts | 7 ------- src/pages/api/contact/means-of-transport.ts | 7 +++++-- src/pages/api/contact/refund.ts | 7 +++++-- src/pages/api/contact/ticket-control.ts | 7 +++++-- src/pages/api/contact/ticketing.ts | 8 +++++--- 5 files changed, 20 insertions(+), 16 deletions(-) delete mode 100644 src/pages/api/contact/contact-api-config.ts diff --git a/src/pages/api/contact/contact-api-config.ts b/src/pages/api/contact/contact-api-config.ts deleted file mode 100644 index fba6a7e9..00000000 --- a/src/pages/api/contact/contact-api-config.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const defaultConfig = { - api: { - bodyParser: { - sizeLimit: '50mb', - }, - }, -}; diff --git a/src/pages/api/contact/means-of-transport.ts b/src/pages/api/contact/means-of-transport.ts index 321ceb79..7bb77166 100644 --- a/src/pages/api/contact/means-of-transport.ts +++ b/src/pages/api/contact/means-of-transport.ts @@ -2,10 +2,13 @@ import { tryResult } from '@atb/modules/api-server'; import { handlerWithContactFormClient } from '@atb/page-modules/contact/server'; import { ContactApiReturnType } from '@atb/page-modules/contact/server/types'; import { NextApiRequest, NextApiResponse } from 'next'; -import { defaultConfig } from './contact-api-config'; export const config = { - ...defaultConfig, + api: { + bodyParser: { + sizeLimit: '50mb', + }, + }, }; export default handlerWithContactFormClient({ diff --git a/src/pages/api/contact/refund.ts b/src/pages/api/contact/refund.ts index f59dbd1b..6a14485c 100644 --- a/src/pages/api/contact/refund.ts +++ b/src/pages/api/contact/refund.ts @@ -2,10 +2,13 @@ import { tryResult } from '@atb/modules/api-server'; import { handlerWithContactFormClient } from '@atb/page-modules/contact/server'; import { ContactApiReturnType } from '@atb/page-modules/contact/server/types'; import { NextApiRequest, NextApiResponse } from 'next'; -import { defaultConfig } from './contact-api-config'; export const config = { - ...defaultConfig, + api: { + bodyParser: { + sizeLimit: '50mb', + }, + }, }; export default handlerWithContactFormClient({ diff --git a/src/pages/api/contact/ticket-control.ts b/src/pages/api/contact/ticket-control.ts index 81e85901..fcc42e20 100644 --- a/src/pages/api/contact/ticket-control.ts +++ b/src/pages/api/contact/ticket-control.ts @@ -2,10 +2,13 @@ import { tryResult } from '@atb/modules/api-server'; import { handlerWithContactFormClient } from '@atb/page-modules/contact/server'; import { ContactApiReturnType } from '@atb/page-modules/contact/server/types'; import { NextApiRequest, NextApiResponse } from 'next'; -import { defaultConfig } from './contact-api-config'; export const config = { - ...defaultConfig, + api: { + bodyParser: { + sizeLimit: '50mb', + }, + }, }; export default handlerWithContactFormClient({ diff --git a/src/pages/api/contact/ticketing.ts b/src/pages/api/contact/ticketing.ts index c0e5e55d..9af014b3 100644 --- a/src/pages/api/contact/ticketing.ts +++ b/src/pages/api/contact/ticketing.ts @@ -2,12 +2,14 @@ import { tryResult } from '@atb/modules/api-server'; import { handlerWithContactFormClient } from '@atb/page-modules/contact/server'; import { ContactApiReturnType } from '@atb/page-modules/contact/server/types'; import { NextApiRequest, NextApiResponse } from 'next'; -import { defaultConfig } from './contact-api-config'; export const config = { - ...defaultConfig, + api: { + bodyParser: { + sizeLimit: '50mb', + }, + }, }; - export default handlerWithContactFormClient({ async POST(req: NextApiRequest, res: NextApiResponse, { client, ok }) { return tryResult(req, res, async () => {