2
0

🐛 Fix api doc CORS

This commit is contained in:
Baptiste Arnaud
2022-11-30 16:27:32 +01:00
parent 3c8820b212
commit 94a57aea21
12 changed files with 68 additions and 38 deletions

View File

@@ -13,6 +13,7 @@
},
"dependencies": {
"@sentry/nextjs": "7.21.1",
"@trpc/server": "10.3.0",
"aws-sdk": "2.1261.0",
"bot-engine": "workspace:*",
"cors": "2.8.5",
@@ -21,14 +22,14 @@
"google-spreadsheet": "3.3.0",
"got": "12.5.3",
"next": "13.0.5",
"nextjs-cors": "^2.1.2",
"nodemailer": "6.8.0",
"qs": "6.11.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"sanitize-html": "2.7.3",
"stripe": "11.1.0",
"trpc-openapi": "1.0.0-alpha.4",
"@trpc/server": "10.3.0"
"trpc-openapi": "1.0.0-alpha.4"
},
"devDependencies": {
"@babel/preset-env": "7.20.2",
@@ -51,10 +52,10 @@
"next-transpile-modules": "10.0.0",
"node-fetch": "^3.3.0",
"papaparse": "5.3.2",
"superjson": "^1.11.0",
"tsconfig": "workspace:*",
"typescript": "4.9.3",
"zod": "3.19.1",
"superjson": "^1.11.0",
"utils": "workspace:*"
"utils": "workspace:*",
"zod": "3.19.1"
}
}

View File

@@ -1,13 +1,22 @@
import { appRouter } from '@/utils/server/routers/v1/_app'
import { captureException } from '@sentry/nextjs'
import { createOpenApiNextHandler } from 'trpc-openapi'
import cors from 'nextjs-cors'
import { NextApiRequest, NextApiResponse } from 'next'
export default createOpenApiNextHandler({
router: appRouter,
onError({ error }) {
if (error.code === 'INTERNAL_SERVER_ERROR') {
captureException(error)
console.error('Something went wrong', error)
}
},
})
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
await cors(req, res, {
origin: 'https://docs.typebot.io',
})
return createOpenApiNextHandler({
router: appRouter,
onError({ error }) {
if (error.code === 'INTERNAL_SERVER_ERROR') {
captureException(error)
console.error('Something went wrong', error)
}
},
})(req, res)
}
export default handler