2
0
Files
bot/apps/builder/next.config.mjs

129 lines
3.6 KiB
JavaScript
Raw Normal View History

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)
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
)
if (process.env.NEXT_PUBLIC_CHAT_API_URL?.includes('{{pr_id}}'))
:zap: Introduce a new high-performing standalone chat API (#1200) Closes #1154 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added authentication functionality for user sessions in chat API. - Introduced chat-related API endpoints for starting, previewing, and continuing chat sessions, and streaming messages. - Implemented WhatsApp API webhook handling for receiving and processing messages. - Added environment variable `NEXT_PUBLIC_CHAT_API_URL` for chat API URL configuration. - **Bug Fixes** - Adjusted file upload logic to correctly determine the API host. - Fixed message streaming URL in chat integration with OpenAI. - **Documentation** - Updated guides for creating blocks, local installation, self-hosting, and deployment to use `bun` instead of `pnpm`. - **Refactor** - Refactored chat API functionalities to use modular architecture. - Simplified client log saving and session update functionalities by using external functions. - Transitioned package management and workflow commands to use `bun`. - **Chores** - Switched to `bun` for package management in Dockerfiles and GitHub workflows. - Added new Dockerfile for chat API service setup with Bun framework. - Updated `.prettierignore` and documentation with new commands. - **Style** - No visible changes to end-users. - **Tests** - No visible changes to end-users. - **Revert** - No reverts in this release. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
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
)
}
injectViewerUrlIfVercelPreview(process.env.NEXT_PUBLIC_VIEWER_URL)
configureRuntimeEnv()
2022-02-14 10:57:57 +01:00
2022-08-08 08:21:36 +02:00
/** @type {import('next').NextConfig} */
const nextConfig = {
2022-08-08 08:21:36 +02:00
reactStrictMode: true,
output: 'standalone',
transpilePackages: [
'@typebot.io/lib',
'@typebot.io/schemas',
'@typebot.io/emails',
'@typebot.io/env',
],
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr', 'pt', 'pt-BR', 'de', 'ro', 'es', 'it', 'el'],
},
experimental: {
outputFileTracingRoot: join(__dirname, '../../'),
2024-05-22 11:42:31 +02:00
serverComponentsExternalPackages: ['isolated-vm'],
},
2024-05-22 11:42:31 +02:00
webpack: (config, { isServer }) => {
if (isServer) return config
config.resolve.alias['minio'] = false
config.resolve.alias['qrcode'] = false
2024-05-22 11:42:31 +02:00
config.resolve.alias['isolated-vm'] = false
return config
},
headers: async () => {
return [
{
source: '/(.*)?',
headers: [
{
key: 'X-Frame-Options',
2023-02-13 18:30:29 +01:00
value: 'SAMEORIGIN',
},
],
},
]
},
async rewrites() {
return process.env.NEXT_PUBLIC_POSTHOG_KEY
? [
{
source: '/ingest/:path*',
destination:
(process.env.NEXT_PUBLIC_POSTHOG_HOST ??
'https://app.posthog.com') + '/:path*',
},
{
source: '/healthz',
destination: '/api/health',
},
]
: [
{
source: '/healthz',
destination: '/api/health',
},
]
},
}
2022-02-14 10:57:57 +01: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
// 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/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: '/monitoring',
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
}
)
: nextConfig