From 9427b2a823805ebbc30a481d84b0804aa9433fce Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 10 Mar 2022 15:33:20 +0100 Subject: [PATCH] =?UTF-8?q?fix(viewer):=20=F0=9F=90=9B=20Link=20to=20publi?= =?UTF-8?q?c=20bot=20CORS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/viewer/pages/api/publicTypebots/[typebotId].ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/viewer/pages/api/publicTypebots/[typebotId].ts b/apps/viewer/pages/api/publicTypebots/[typebotId].ts index 11f5688c2..34efcdff2 100644 --- a/apps/viewer/pages/api/publicTypebots/[typebotId].ts +++ b/apps/viewer/pages/api/publicTypebots/[typebotId].ts @@ -1,9 +1,13 @@ import { withSentry } from '@sentry/nextjs' import prisma from 'libs/prisma' import { NextApiRequest, NextApiResponse } from 'next' -import { methodNotAllowed, notFound } from 'utils' +import Cors from 'cors' +import { initMiddleware, methodNotAllowed, notFound } from 'utils' + +const cors = initMiddleware(Cors()) const handler = async (req: NextApiRequest, res: NextApiResponse) => { + await cors(req, res) if (req.method === 'GET') { const typebotId = req.query.typebotId as string const typebot = await prisma.publicTypebot.findUnique({