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-03-09 22:56:05 +00:00
"@calcom/ee" ,
"@calcom/lib" ,
"@calcom/prisma" ,
"@calcom/stripe" ,
"@calcom/ui" ,
2022-03-31 08:45:47 +00:00
"@calcom/embed-core" ,
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
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
}
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 ( ) {
return [
{
source : "/:user/avatar.png" ,
destination : "/api/user/avatar?username=:user" ,
} ,
2022-04-27 11:08:13 +00:00
{
source : "/team/:teamname/avatar.png" ,
destination : "/api/user/avatar?teamname=:teamname" ,
} ,
2022-03-26 00:39:38 +00:00
] ;
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 ) ;