2023-08-28 09:13:53 +02:00
|
|
|
import { withSentryConfig } from '@sentry/nextjs'
|
|
|
|
import { join, dirname } from 'path'
|
|
|
|
import '@typebot.io/env/dist/env.mjs'
|
|
|
|
import { configureRuntimeEnv } from 'next-runtime-env/build/configure.js'
|
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
|
|
|
|
|
|
const __dirname = dirname(__filename)
|
|
|
|
|
2023-12-05 10:59:19 +01:00
|
|
|
const injectViewerUrlIfVercelPreview = (val) => {
|
|
|
|
if (
|
|
|
|
(val && typeof val === 'string' && val.length > 0) ||
|
|
|
|
process.env.VERCEL_ENV !== 'preview' ||
|
|
|
|
!process.env.VERCEL_BUILDER_PROJECT_NAME ||
|
|
|
|
!process.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME
|
|
|
|
)
|
|
|
|
return
|
|
|
|
process.env.NEXT_PUBLIC_VIEWER_URL =
|
|
|
|
`https://${process.env.VERCEL_BRANCH_URL}`.replace(
|
|
|
|
process.env.VERCEL_BUILDER_PROJECT_NAME,
|
|
|
|
process.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME
|
|
|
|
)
|
2024-04-05 09:01:16 +02:00
|
|
|
if (process.env.NEXT_PUBLIC_CHAT_API_URL?.includes('{{pr_id}}'))
|
2024-03-21 10:23:23 +01:00
|
|
|
process.env.NEXT_PUBLIC_CHAT_API_URL =
|
|
|
|
process.env.NEXT_PUBLIC_CHAT_API_URL.replace(
|
|
|
|
'{{pr_id}}',
|
|
|
|
process.env.VERCEL_GIT_PULL_REQUEST_ID
|
|
|
|
)
|
2023-12-05 10:59:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
injectViewerUrlIfVercelPreview(process.env.NEXT_PUBLIC_VIEWER_URL)
|
|
|
|
|
2023-08-28 09:13:53 +02:00
|
|
|
configureRuntimeEnv()
|
2022-02-14 10:57:57 +01:00
|
|
|
|
2022-08-08 08:21:36 +02:00
|
|
|
/** @type {import('next').NextConfig} */
|
2023-03-15 08:35:16 +01:00
|
|
|
const nextConfig = {
|
2022-08-08 08:21:36 +02:00
|
|
|
reactStrictMode: true,
|
|
|
|
output: 'standalone',
|
2023-03-15 08:35:16 +01:00
|
|
|
transpilePackages: [
|
|
|
|
'@typebot.io/lib',
|
|
|
|
'@typebot.io/schemas',
|
|
|
|
'@typebot.io/emails',
|
2023-08-28 09:13:53 +02:00
|
|
|
'@typebot.io/env',
|
2023-03-15 08:35:16 +01:00
|
|
|
],
|
2023-03-11 11:05:07 +01:00
|
|
|
i18n: {
|
|
|
|
defaultLocale: 'en',
|
2024-07-17 10:58:34 +02:00
|
|
|
locales: ['en', 'fr', 'pt', 'pt-BR', 'de', 'ro', 'es', 'it', 'el'],
|
2023-03-11 11:05:07 +01:00
|
|
|
},
|
2022-03-12 07:53:37 +01:00
|
|
|
experimental: {
|
2023-08-28 09:13:53 +02:00
|
|
|
outputFileTracingRoot: join(__dirname, '../../'),
|
2024-05-22 11:42:31 +02:00
|
|
|
serverComponentsExternalPackages: ['isolated-vm'],
|
2022-03-12 07:53:37 +01:00
|
|
|
},
|
2024-05-22 11:42:31 +02:00
|
|
|
webpack: (config, { isServer }) => {
|
|
|
|
if (isServer) return config
|
2023-12-13 10:22:02 +01:00
|
|
|
|
|
|
|
config.resolve.alias['minio'] = false
|
2024-04-05 09:01:16 +02:00
|
|
|
config.resolve.alias['qrcode'] = false
|
2024-05-22 11:42:31 +02:00
|
|
|
config.resolve.alias['isolated-vm'] = false
|
2023-12-13 10:22:02 +01:00
|
|
|
return config
|
|
|
|
},
|
2023-01-18 20:56:48 +01:00
|
|
|
headers: async () => {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
source: '/(.*)?',
|
|
|
|
headers: [
|
|
|
|
{
|
|
|
|
key: 'X-Frame-Options',
|
2023-02-13 18:30:29 +01:00
|
|
|
value: 'SAMEORIGIN',
|
2023-01-18 20:56:48 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
2023-08-29 10:01:28 +02:00
|
|
|
async rewrites() {
|
|
|
|
return process.env.NEXT_PUBLIC_POSTHOG_KEY
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
source: '/ingest/:path*',
|
|
|
|
destination:
|
|
|
|
(process.env.NEXT_PUBLIC_POSTHOG_HOST ??
|
|
|
|
'https://app.posthog.com') + '/:path*',
|
|
|
|
},
|
2024-06-11 22:35:12 +05:30
|
|
|
{
|
|
|
|
source: '/healthz',
|
|
|
|
destination: '/api/health',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: [
|
|
|
|
{
|
|
|
|
source: '/healthz',
|
|
|
|
destination: '/api/health',
|
|
|
|
},
|
2023-08-29 10:01:28 +02:00
|
|
|
]
|
|
|
|
},
|
2023-03-15 08:35:16 +01:00
|
|
|
}
|
2022-02-14 10:57:57 +01:00
|
|
|
|
2023-10-10 15:04:17 +02:00
|
|
|
export default process.env.NEXT_PUBLIC_SENTRY_DSN
|
|
|
|
? withSentryConfig(
|
|
|
|
nextConfig,
|
|
|
|
{
|
|
|
|
// For all available options, see:
|
|
|
|
// https://github.com/getsentry/sentry-webpack-plugin#options
|
2022-02-14 10:57:57 +01:00
|
|
|
|
2023-10-10 15:04:17 +02:00
|
|
|
// Suppresses source map uploading logs during build
|
|
|
|
silent: true,
|
|
|
|
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-builder',
|
|
|
|
org: process.env.SENTRY_ORG,
|
|
|
|
project: process.env.SENTRY_PROJECT,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// For all available options, see:
|
|
|
|
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
2023-10-07 12:03:42 +02:00
|
|
|
|
2023-10-10 15:04:17 +02:00
|
|
|
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
|
|
widenClientFileUpload: true,
|
2023-10-07 12:03:42 +02:00
|
|
|
|
2023-10-10 15:04:17 +02:00
|
|
|
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
|
|
|
|
tunnelRoute: '/monitoring',
|
2023-10-07 12:03:42 +02:00
|
|
|
|
2023-10-10 15:04:17 +02:00
|
|
|
// Hides source maps from generated client bundles
|
|
|
|
hideSourceMaps: true,
|
2023-10-07 12:03:42 +02:00
|
|
|
|
2023-10-10 15:04:17 +02:00
|
|
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
|
|
disableLogger: true,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
: nextConfig
|