cal.pub0.org/apps/web/next.config.js

107 lines
2.9 KiB
JavaScript
Raw Normal View History

const withTM = require("@vercel/edge-functions-ui/transpile")([
2022-02-21 23:14:46 +00:00
"@calcom/app-store",
"@calcom/lib",
"@calcom/prisma",
"@calcom/ui",
]);
const { i18n } = require("./next-i18next.config");
2021-09-21 20:18:41 +00:00
// So we can test deploy previews preview
if (process.env.VERCEL_URL && !process.env.BASE_URL) {
process.env.BASE_URL = "https://" + process.env.VERCEL_URL;
2021-09-21 20:18:41 +00:00
}
if (process.env.BASE_URL) {
process.env.NEXTAUTH_URL = process.env.BASE_URL + "/api/auth";
}
if (!process.env.NEXT_PUBLIC_APP_URL) {
process.env.NEXT_PUBLIC_APP_URL = process.env.BASE_URL;
}
process.env.NEXT_PUBLIC_BASE_URL = process.env.BASE_URL;
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."
);
}
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-07-20 18:18:26 +00:00
} catch (e) {
console.error(e);
}
return false;
};
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.'
);
}
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);
// prettier-ignore
module.exports = () => plugins.reduce((acc, next) => next(acc), {
i18n,
eslint: {
// This allows production builds to successfully complete even if the project has ESLint errors.
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
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;
},
async rewrites() {
return [
{
source: "/:user/avatar.png",
destination: "/api/user/avatar?username=:user",
},
]
},
async redirects() {
return [
{
2021-07-20 18:18:26 +00:00
source: "/settings",
destination: "/settings/profile",
permanent: true,
2021-07-20 18:18:26 +00:00
},
{
source: "/bookings",
destination: "/bookings/upcoming",
permanent: true,
},
{
source: '/call/:path*',
destination: '/video/:path*',
permanent: false
}
2021-07-20 18:18:26 +00:00
];
},
});