✨ Allow user to share a flow publicly and make it duplicatable
Closes #360
This commit is contained in:
24
apps/builder/src/pages/api/[...trpc].ts
Normal file
24
apps/builder/src/pages/api/[...trpc].ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createContext } from '@/helpers/server/context'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { createOpenApiNextHandler } from 'trpc-openapi'
|
||||
import cors from 'nextjs-cors'
|
||||
import { publicRouter } from '@/helpers/server/routers/publicRouter'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
await cors(req, res, {
|
||||
origin: ['https://docs.typebot.io', 'http://localhost:3000'],
|
||||
})
|
||||
|
||||
return createOpenApiNextHandler({
|
||||
router: publicRouter,
|
||||
createContext,
|
||||
onError({ error }) {
|
||||
if (error.code === 'INTERNAL_SERVER_ERROR') {
|
||||
Sentry.captureException(error)
|
||||
console.error('Something went wrong', error)
|
||||
}
|
||||
},
|
||||
})(req, res)
|
||||
}
|
||||
export default handler
|
||||
Reference in New Issue
Block a user