diff --git a/functions/src/gateway/controller.ts b/functions/src/gateway/controller.ts index ae3ff0ab..e7b9a1b7 100644 --- a/functions/src/gateway/controller.ts +++ b/functions/src/gateway/controller.ts @@ -10,6 +10,7 @@ import {getAppCheck} from 'firebase-admin/app-check'; import {avatars} from './avatars'; import {me} from './me'; import {spokenToSigned} from './spoken-to-signed'; +import {optionsRequest} from '../middlewares/options.request'; // The public APP ID of the sign-mt web app const APP_ID = '1:665830225099:web:18e0669d5847a4b047974e'; @@ -50,7 +51,7 @@ const app: Application = express(); app.use(cors()); app.use(unkeyAuth); app.use(getAppCheckKey); -app.options('*', (req, res) => res.status(200).end()); +app.options('*', optionsRequest); spokenToSigned(app); me(app); diff --git a/functions/src/middlewares/options.request.ts b/functions/src/middlewares/options.request.ts new file mode 100644 index 00000000..891eeeff --- /dev/null +++ b/functions/src/middlewares/options.request.ts @@ -0,0 +1,5 @@ +import * as express from 'express'; + +export function optionsRequest(req: express.Request, res: express.Response) { + res.status(200).end(); +} diff --git a/functions/src/text-normalization/controller.ts b/functions/src/text-normalization/controller.ts index 66a7c749..d652394a 100644 --- a/functions/src/text-normalization/controller.ts +++ b/functions/src/text-normalization/controller.ts @@ -9,6 +9,7 @@ import {onRequest} from 'firebase-functions/v2/https'; import {defineString} from 'firebase-functions/params'; import {appCheckVerification} from '../middlewares/appcheck.middleware'; import type {StringParam} from 'firebase-functions/lib/params/types'; +import {optionsRequest} from '../middlewares/options.request'; export class TextNormalizationEndpoint { constructor(private database: FirebaseDatabase, private OpenAIApiKey: StringParam) {} @@ -106,7 +107,7 @@ export const textNormalizationFunctions = (database: FirebaseDatabase) => { const app = express(); app.use(cors()); app.use(appCheckVerification); - app.options('*', (req, res) => res.status(200).end()); + app.options('*', optionsRequest); app.get(['/', '/api/text-normalization'], request); app.use(errorMiddleware);