2022-03-26 00:39:38 +00:00
require ( "dotenv" ) . config ( { path : "../../.env" } ) ;
2022-03-09 22:56:05 +00:00
const withTM = require ( "next-transpile-modules" ) ( [
2022-03-23 22:00:30 +00:00
"@calcom/app-store" ,
"@calcom/core" ,
2022-06-28 20:40:58 +00:00
"@calcom/dayjs" ,
2022-03-09 22:56:05 +00:00
"@calcom/ee" ,
"@calcom/lib" ,
"@calcom/prisma" ,
"@calcom/stripe" ,
"@calcom/ui" ,
2022-06-06 17:49:56 +00:00
"@calcom/emails" ,
2022-03-31 08:45:47 +00:00
"@calcom/embed-core" ,
2022-07-06 20:34:49 +00:00
"@calcom/embed-react" ,
2022-05-05 14:29:49 +00:00
"@calcom/embed-snippet" ,
2022-03-09 22:56:05 +00:00
] ) ;
2021-09-23 08:49:17 +00:00
const { i18n } = require ( "./next-i18next.config" ) ;
2021-04-26 12:01:21 +00:00
2022-06-03 16:50:48 +00:00
if ( ! process . env . NEXTAUTH _SECRET ) throw new Error ( "Please set NEXTAUTH_SECRET" ) ;
if ( ! process . env . CALENDSO _ENCRYPTION _KEY ) throw new Error ( "Please set CALENDSO_ENCRYPTION_KEY" ) ;
2021-09-21 20:18:41 +00:00
// So we can test deploy previews preview
2022-03-26 00:39:38 +00:00
if ( process . env . VERCEL _URL && ! process . env . NEXT _PUBLIC _WEBAPP _URL ) {
process . env . NEXT _PUBLIC _WEBAPP _URL = "https://" + process . env . VERCEL _URL ;
2021-09-21 20:18:41 +00:00
}
2022-03-26 00:39:38 +00:00
if ( process . env . NEXT _PUBLIC _WEBAPP _URL ) {
process . env . NEXTAUTH _URL = process . env . NEXT _PUBLIC _WEBAPP _URL + "/api/auth" ;
2021-06-07 16:38:46 +00:00
}
2022-03-26 00:39:38 +00:00
if ( ! process . env . NEXT _PUBLIC _WEBSITE _URL ) {
process . env . NEXT _PUBLIC _WEBSITE _URL = process . env . NEXT _PUBLIC _WEBAPP _URL ;
2021-09-22 18:36:13 +00:00
}
2021-06-07 16:38:46 +00:00
2021-07-20 18:18:26 +00:00
if ( ! process . env . EMAIL _FROM ) {
console . warn (
"\x1b[33mwarn" ,
"\x1b[0m" ,
"EMAIL_FROM environment variable is not set, this may indicate mailing is currently disabled. Please refer to the .env.example file."
) ;
2021-05-27 22:10:20 +00:00
}
2022-06-03 18:48:47 +00:00
if ( ! process . env . NEXTAUTH _URL ) throw new Error ( "Please set NEXTAUTH_URL" ) ;
2021-05-04 20:31:15 +00:00
const validJson = ( jsonString ) => {
2021-07-20 18:18:26 +00:00
try {
const o = JSON . parse ( jsonString ) ;
if ( o && typeof o === "object" ) {
return o ;
2021-05-04 20:31:15 +00:00
}
2021-07-20 18:18:26 +00:00
} catch ( e ) {
console . error ( e ) ;
}
return false ;
} ;
2021-05-04 20:31:15 +00:00
2021-07-20 18:18:26 +00:00
if ( process . env . GOOGLE _API _CREDENTIALS && ! validJson ( process . env . GOOGLE _API _CREDENTIALS ) ) {
console . warn (
"\x1b[33mwarn" ,
"\x1b[0m" ,
'- Disabled \'Google Calendar\' integration. Reason: Invalid value for GOOGLE_API_CREDENTIALS environment variable. When set, this value needs to contain valid JSON like {"web":{"client_id":"<clid>","client_secret":"<secret>","redirect_uris":["<yourhost>/api/integrations/googlecalendar/callback>"]}. You can download this JSON from your OAuth Client @ https://console.cloud.google.com/apis/credentials.'
) ;
2021-05-04 20:31:15 +00:00
}
2021-10-20 09:08:58 +00:00
const plugins = [ ] ;
if ( process . env . ANALYZE === "true" ) {
// only load dependency if env `ANALYZE` was set
const withBundleAnalyzer = require ( "@next/bundle-analyzer" ) ( {
enabled : true ,
} ) ;
plugins . push ( withBundleAnalyzer ) ;
}
plugins . push ( withTM ) ;
2021-09-29 14:36:58 +00:00
2022-03-26 00:39:38 +00:00
/** @type {import("next").NextConfig} */
const nextConfig = {
2021-09-23 08:49:17 +00:00
i18n ,
2021-09-09 13:51:06 +00:00
webpack : ( config ) => {
config . resolve . fallback = {
... config . resolve . fallback , // if you miss it, all the other options in fallback, specified
// by next.js will be dropped. Doesn't make much sense, but how it is
fs : false ,
} ;
return config ;
} ,
2022-01-11 08:54:02 +00:00
async rewrites ( ) {
2022-07-14 20:56:00 +00:00
return [
{
source : "/:user/avatar.png" ,
destination : "/api/user/avatar?username=:user" ,
} ,
{
source : "/team/:teamname/avatar.png" ,
destination : "/api/user/avatar?teamname=:teamname" ,
} ,
2022-07-15 11:46:05 +00:00
{
source : "/forms/:formId" ,
destination : "/apps/routing_forms/routing-link/:formId" ,
} ,
2022-07-14 20:56:00 +00:00
/ * T O D O : h a v e t h e s e f i l e s b e i n g s e r v e d f r o m a n o t h e r d e p l o y m e n t o r C D N {
source : "/embed/embed.js" ,
destination : process . env . NEXT _PUBLIC _EMBED _LIB _URL ? ,
} , * /
] ;
2022-01-11 08:54:02 +00:00
} ,
2021-05-07 15:04:56 +00:00
async redirects ( ) {
2022-05-02 20:39:35 +00:00
const redirects = [
2021-05-07 15:04:56 +00:00
{
2021-07-20 18:18:26 +00:00
source : "/settings" ,
destination : "/settings/profile" ,
2021-05-07 15:04:56 +00:00
permanent : true ,
2021-07-20 18:18:26 +00:00
} ,
2021-09-29 21:33:18 +00:00
{
source : "/bookings" ,
destination : "/bookings/upcoming" ,
permanent : true ,
} ,
2022-02-15 15:13:27 +00:00
{
2022-03-26 00:39:38 +00:00
source : "/call/:path*" ,
destination : "/video/:path*" ,
permanent : false ,
} ,
2021-07-20 18:18:26 +00:00
] ;
2022-05-02 20:39:35 +00:00
if ( process . env . NEXT _PUBLIC _WEBAPP _URL === "https://app.cal.com" ) {
redirects . push (
{
source : "/apps/dailyvideo" ,
destination : "/apps/daily-video" ,
permanent : true ,
} ,
{
source : "/apps/huddle01_video" ,
destination : "/apps/huddle01" ,
permanent : true ,
} ,
{
source : "/apps/jitsi_video" ,
destination : "/apps/jitsi" ,
permanent : true ,
}
) ;
}
return redirects ;
2021-07-20 18:18:26 +00:00
} ,
2022-03-26 00:39:38 +00:00
} ;
module . exports = ( ) => plugins . reduce ( ( acc , next ) => next ( acc ) , nextConfig ) ;