163c7ff791
* refactor: replace i18n HTTP requests with build-time bundling - Create translationBundler.ts for build-time translation loading - Replace HTTP fetch in loadTranslations with file system reads - Add CalComVersion cache invalidation to prevent stale translations - Fix TypeScript errors in booking page components - Eliminate 60s timeout issues by removing network dependency Resolves translation timeout issues by bundling translations at build time instead of making runtime HTTP requests to /static/locales/ endpoints. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: move i18n files back to packages/lib/server with proper imports - Move i18n.ts and translationBundler.ts back to packages/lib/server/ - Replace all relative imports with @calcom/lib/server/i18n pattern - Fix LOCALES_PATH to point to correct directory - Maintain optimized serverless-friendly translation loading Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: move locale files to packages/lib/server to eliminate circular deps - Move all locale files from apps/web/public/static/locales to packages/lib/server/locales - Create copy-locales-static.js script to copy files during build - Update all references to use new location for build-time access - Maintain public folder copying for Next.js runtime access - Update platform atoms, scripts, and config files - Fix copy script relative path issue Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: update test imports after locale refactor - Fix import paths in test files updated by pre-commit hooks - Ensure all tests use correct locale import paths Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: revert import paths from @calcom/web/lib/i18n to @calcom/lib/server/i18n - Revert all test file imports back to @calcom/lib/server/i18n as requested - Addresses GitHub comment feedback to stick with packages/lib/server location - Fixes import paths in 6 test files that were incorrectly changed Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: update vite config alias to use new locale path - Update @calcom/web/public/static/locales/en/common.json to @calcom/lib/server/locales/en/common.json - Addresses GitHub comment about updating platform atoms vite config - Maintains correct path resolution after locale files moved to packages/lib/server Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: update translationBundler path resolution for production builds - Use process.cwd() instead of __dirname for locale file path resolution - Ensures locale files can be found in both development and production environments - Fixes E2E test failures caused by missing locale files in .next/server/chunks/ Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use relative path resolution for locale files in translationBundler - Change from process.cwd() to __dirname with relative paths - Ensures locale files can be found in both development and production environments - Fixes E2E test failures caused by incorrect path resolution in Next.js builds Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use process.cwd() for locale path resolution in production builds - Change from __dirname to process.cwd() with relative paths - Ensures locale files can be found when bundled into Next.js server chunks - Fixes E2E test failures caused by incorrect path resolution in production environment - Follows same pattern used in getStaticProps.tsx for cross-package file access Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use path.resolve pattern from sendVerificationRequest for locale access - Change from process.cwd() to path.resolve(process.cwd(), '..', '..', 'packages/lib/server/locales') - Follows same pattern used in sendVerificationRequest.ts for cross-environment file access - Should resolve E2E test failures by ensuring locale files can be found when bundled into Next.js server chunks - Pattern navigates up from current working directory to reach packages directory consistently Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use dynamic monorepo root detection for locale path resolution - Replace relative path resolution with dynamic monorepo root finder - Ensures locale files can be found from any working directory (root, apps/web, apps/api/v2) - Update API v2 i18n config to use new locale path - Fixes remaining E2E test failures in API v2 and E2E (1/4) test suites Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: use require.resolve(__filename) for robust path resolution in all contexts - Replace __dirname with require.resolve(__filename) in monorepo root detection - Ensures locale files can be found when running from any working directory - Fixes E2E API v2 test failures where __dirname resolves to '.' instead of actual file path Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Revert "fix: use require.resolve(__filename) for robust path resolution in all contexts" This reverts commit b37d8226000da8f7d5fb98b83dd0e95a53d45372. * fix: update copied locale files after translationBundler path resolution fix - Copy script updated all locale files in public directory - Ensures E2E tests have access to latest locale files - Fixes regression where all E2E tests were failing Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * feat: remove existing locale files to establish copy script as single source of truth - Delete all common.json files from apps/web/public/static/locales/ - Eliminates developer confusion about which files are authoritative - copy-locales-static.js script now clearly the only mechanism for populating public folder - packages/lib/server/locales/ remains the definitive source of truth for translations Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * add comment * refactor: simplify findMonorepoRoot by removing redundant fallback loop - Remove unnecessary second while loop using process.cwd() - The first loop from __dirname will always find the monorepo root - Add clear error message for fail-fast behavior if repo structure is corrupted - Improves code clarity and maintainability Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * feat: integrate updated translations from main branch - Restore all common.json files from main branch to apps/web/public/static/locales/ - Overwrite packages/lib/server/locales/ with up-to-date translation content - Resolve merge conflicts using Benny's safer 2-step approach - Ensure translation source of truth remains in packages/lib/server/locales/ - Complete safer conflict resolution to eliminate merge conflicts on PR #22422 Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * chore: update package.json and yarn.lock after translation integration - Update dependencies after ts-node installation for pre-commit hooks - Ensure yarn.lock reflects current dependency state - Complete translation integration process Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * feat: remove duplicate locale files from apps/web to establish single source of truth - Delete all common.json files from apps/web/public/static/locales/ - Maintain packages/lib/server/locales/ as the single source of truth for translations - copy-locales-static.js script will populate public folder during build process - Complete Benny's safer 2-step approach: restore from main, then remove duplicates - Resolve merge conflicts and eliminate developer confusion about translation file locations Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: hbjORbj <sldisek783@gmail.com>
681 lines
19 KiB
JavaScript
681 lines
19 KiB
JavaScript
require("dotenv").config({ path: "../../.env" });
|
|
const englishTranslation = require("../../packages/lib/server/locales/en/common.json");
|
|
const { withAxiom } = require("next-axiom");
|
|
const { version } = require("./package.json");
|
|
const {
|
|
i18n: { locales },
|
|
} = require("./next-i18next.config");
|
|
const {
|
|
nextJsOrgRewriteConfig,
|
|
orgUserRoutePath,
|
|
orgUserTypeRoutePath,
|
|
orgUserTypeEmbedRoutePath,
|
|
} = require("./pagesAndRewritePaths");
|
|
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");
|
|
const isOrganizationsEnabled =
|
|
process.env.ORGANIZATIONS_ENABLED === "1" || process.env.ORGANIZATIONS_ENABLED === "true";
|
|
// To be able to use the version in the app without having to import package.json
|
|
process.env.NEXT_PUBLIC_CALCOM_VERSION = version;
|
|
|
|
// So we can test deploy previews preview
|
|
if (process.env.VERCEL_URL && !process.env.NEXT_PUBLIC_WEBAPP_URL) {
|
|
process.env.NEXT_PUBLIC_WEBAPP_URL = `https://${process.env.VERCEL_URL}`;
|
|
}
|
|
// Check for configuration of NEXTAUTH_URL before overriding
|
|
if (!process.env.NEXTAUTH_URL && process.env.NEXT_PUBLIC_WEBAPP_URL) {
|
|
process.env.NEXTAUTH_URL = `${process.env.NEXT_PUBLIC_WEBAPP_URL}/api/auth`;
|
|
}
|
|
if (!process.env.NEXT_PUBLIC_WEBSITE_URL) {
|
|
process.env.NEXT_PUBLIC_WEBSITE_URL = process.env.NEXT_PUBLIC_WEBAPP_URL;
|
|
}
|
|
if (
|
|
process.env.CSP_POLICY === "strict" &&
|
|
(process.env.CALCOM_ENV === "production" || process.env.NODE_ENV === "production")
|
|
) {
|
|
throw new Error(
|
|
"Strict CSP policy(for style-src) is not yet supported in production. You can experiment with it in Dev Mode"
|
|
);
|
|
}
|
|
|
|
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."
|
|
);
|
|
}
|
|
|
|
if (!process.env.NEXTAUTH_URL) throw new Error("Please set NEXTAUTH_URL");
|
|
|
|
const getHttpsUrl = (url) => {
|
|
if (!url) return url;
|
|
if (url.startsWith("http://")) {
|
|
return url.replace("http://", "https://");
|
|
}
|
|
return url;
|
|
};
|
|
|
|
if (process.argv.includes("--experimental-https")) {
|
|
process.env.NEXT_PUBLIC_WEBAPP_URL = getHttpsUrl(process.env.NEXT_PUBLIC_WEBAPP_URL);
|
|
process.env.NEXTAUTH_URL = getHttpsUrl(process.env.NEXTAUTH_URL);
|
|
process.env.NEXT_PUBLIC_EMBED_LIB_URL = getHttpsUrl(process.env.NEXT_PUBLIC_EMBED_LIB_URL);
|
|
}
|
|
|
|
const validJson = (jsonString) => {
|
|
try {
|
|
const o = JSON.parse(jsonString);
|
|
if (o && typeof o === "object") {
|
|
return o;
|
|
}
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
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 informAboutDuplicateTranslations = () => {
|
|
const valueMap = {};
|
|
|
|
for (const key in englishTranslation) {
|
|
const value = englishTranslation[key];
|
|
|
|
if (valueMap[value]) {
|
|
console.warn(
|
|
"\x1b[33mDuplicate value found in common.json keys:",
|
|
"\x1b[0m ",
|
|
key,
|
|
"and",
|
|
valueMap[value]
|
|
);
|
|
} else {
|
|
valueMap[value] = key;
|
|
}
|
|
}
|
|
};
|
|
|
|
informAboutDuplicateTranslations();
|
|
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(withAxiom);
|
|
const orgDomainMatcherConfig = {
|
|
root: nextJsOrgRewriteConfig.disableRootPathRewrite
|
|
? null
|
|
: {
|
|
has: [
|
|
{
|
|
type: "host",
|
|
value: nextJsOrgRewriteConfig.orgHostPath,
|
|
},
|
|
],
|
|
source: "/",
|
|
},
|
|
|
|
rootEmbed: nextJsOrgRewriteConfig.disableRootEmbedPathRewrite
|
|
? null
|
|
: {
|
|
has: [
|
|
{
|
|
type: "host",
|
|
value: nextJsOrgRewriteConfig.orgHostPath,
|
|
},
|
|
],
|
|
source: "/embed",
|
|
},
|
|
|
|
user: {
|
|
has: [
|
|
{
|
|
type: "host",
|
|
value: nextJsOrgRewriteConfig.orgHostPath,
|
|
},
|
|
],
|
|
source: orgUserRoutePath,
|
|
},
|
|
|
|
userType: {
|
|
has: [
|
|
{
|
|
type: "host",
|
|
value: nextJsOrgRewriteConfig.orgHostPath,
|
|
},
|
|
],
|
|
source: orgUserTypeRoutePath,
|
|
},
|
|
|
|
userTypeEmbed: {
|
|
has: [
|
|
{
|
|
type: "host",
|
|
value: nextJsOrgRewriteConfig.orgHostPath,
|
|
},
|
|
],
|
|
source: orgUserTypeEmbedRoutePath,
|
|
},
|
|
};
|
|
|
|
/** @type {import("next").NextConfig} */
|
|
const nextConfig = {
|
|
output: process.env.BUILD_STANDALONE === "true" ? "standalone" : undefined,
|
|
serverExternalPackages: [
|
|
"deasync",
|
|
"http-cookie-agent", // Dependencies of @ewsjs/xhr
|
|
"rest-facade",
|
|
"superagent-proxy", // Dependencies of @tryvital/vital-node
|
|
"superagent", // Dependencies of akismet
|
|
"formidable", // Dependencies of akismet
|
|
],
|
|
experimental: {
|
|
// externalize server-side node_modules with size > 1mb, to improve dev mode performance/RAM usage
|
|
optimizePackageImports: ["@calcom/ui"],
|
|
},
|
|
productionBrowserSourceMaps: true,
|
|
/* We already do type check on GH actions */
|
|
typescript: {
|
|
ignoreBuildErrors: !!process.env.CI,
|
|
},
|
|
/* We already do linting on GH actions */
|
|
eslint: {
|
|
ignoreDuringBuilds: !!process.env.CI,
|
|
},
|
|
transpilePackages: [
|
|
"@calcom/app-store",
|
|
"@calcom/dayjs",
|
|
"@calcom/emails",
|
|
"@calcom/embed-core",
|
|
"@calcom/embed-react",
|
|
"@calcom/embed-snippet",
|
|
"@calcom/features",
|
|
"@calcom/lib",
|
|
"@calcom/prisma",
|
|
"@calcom/trpc",
|
|
],
|
|
modularizeImports: {
|
|
"@calcom/features/insights/components": {
|
|
transform: "@calcom/features/insights/components/{{member}}",
|
|
skipDefaultConversion: true,
|
|
preventFullImport: true,
|
|
},
|
|
lodash: {
|
|
transform: "lodash/{{member}}",
|
|
},
|
|
},
|
|
images: {
|
|
unoptimized: true,
|
|
},
|
|
webpack: (config, { webpack, buildId, isServer }) => {
|
|
if (isServer) {
|
|
// Module not found fix @see https://github.com/boxyhq/jackson/issues/1535#issuecomment-1704381612
|
|
config.plugins.push(
|
|
new webpack.IgnorePlugin({
|
|
resourceRegExp:
|
|
/(^@google-cloud\/spanner|^@mongodb-js\/zstd|^@sap\/hana-client\/extension\/Stream$|^@sap\/hana-client|^@sap\/hana-client$|^aws-crt|^aws4$|^better-sqlite3$|^bson-ext$|^cardinal$|^cloudflare:sockets$|^hdb-pool$|^ioredis$|^kerberos$|^mongodb-client-encryption$|^mysql$|^oracledb$|^pg-native$|^pg-query-stream$|^react-native-sqlite-storage$|^snappy\/package\.json$|^snappy$|^sql.js$|^sqlite3$|^typeorm-aurora-data-api-driver$)/,
|
|
})
|
|
);
|
|
|
|
config.externals.push("formidable");
|
|
}
|
|
|
|
config.plugins.push(new webpack.DefinePlugin({ "process.env.BUILD_ID": JSON.stringify(buildId) }));
|
|
|
|
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,
|
|
// ignore module resolve errors caused by the server component bundler
|
|
"pg-native": false,
|
|
};
|
|
|
|
/**
|
|
* TODO: Find more possible barrels for this project.
|
|
* @see https://github.com/vercel/next.js/issues/12557#issuecomment-1196931845
|
|
**/
|
|
config.module.rules.push({
|
|
test: [/lib\/.*.tsx?/i],
|
|
sideEffects: false,
|
|
});
|
|
|
|
return config;
|
|
},
|
|
async rewrites() {
|
|
const { orgSlug } = nextJsOrgRewriteConfig;
|
|
const beforeFiles = [
|
|
{
|
|
// This should be the first item in `beforeFiles` to take precedence over other rewrites
|
|
source: `/(${locales.join("|")})/:path*`,
|
|
destination: "/:path*",
|
|
},
|
|
{
|
|
source: "/forms/:formQuery*",
|
|
destination: "/apps/routing-forms/routing-link/:formQuery*",
|
|
},
|
|
{
|
|
source: "/routing",
|
|
destination: "/routing/forms",
|
|
},
|
|
{
|
|
source: "/routing/:path*",
|
|
destination: "/apps/routing-forms/:path*",
|
|
},
|
|
{
|
|
source: "/success/:path*",
|
|
has: [
|
|
{
|
|
type: "query",
|
|
key: "uid",
|
|
value: "(?<uid>.*)",
|
|
},
|
|
],
|
|
destination: "/booking/:uid/:path*",
|
|
},
|
|
{
|
|
source: "/cancel/:path*",
|
|
destination: "/booking/:path*",
|
|
},
|
|
{
|
|
/**
|
|
* Needed due to the introduction of dotted usernames
|
|
* @see https://github.com/calcom/cal.com/pull/11706
|
|
*/
|
|
source: "/embed.js",
|
|
destination: "/embed/embed.js",
|
|
},
|
|
{
|
|
source: "/login",
|
|
destination: "/auth/login",
|
|
},
|
|
// These rewrites are other than booking pages rewrites and so that they aren't redirected to org pages ensure that they happen in beforeFiles
|
|
...(isOrganizationsEnabled
|
|
? [
|
|
orgDomainMatcherConfig.root
|
|
? {
|
|
...orgDomainMatcherConfig.root,
|
|
destination: `/team/${orgSlug}?isOrgProfile=1`,
|
|
}
|
|
: null,
|
|
orgDomainMatcherConfig.rootEmbed
|
|
? {
|
|
...orgDomainMatcherConfig.rootEmbed,
|
|
destination: `/team/${orgSlug}/embed?isOrgProfile=1`,
|
|
}
|
|
: null,
|
|
{
|
|
...orgDomainMatcherConfig.user,
|
|
destination: `/org/${orgSlug}/:user`,
|
|
},
|
|
{
|
|
...orgDomainMatcherConfig.userType,
|
|
destination: `/org/${orgSlug}/:user/:type`,
|
|
},
|
|
{
|
|
...orgDomainMatcherConfig.userTypeEmbed,
|
|
destination: `/org/${orgSlug}/:user/:type/embed`,
|
|
},
|
|
]
|
|
: []),
|
|
].filter(Boolean);
|
|
|
|
let afterFiles = [
|
|
{
|
|
source: "/org/:slug",
|
|
destination: "/team/:slug",
|
|
},
|
|
{
|
|
source: "/org/:orgSlug/avatar.png",
|
|
destination: "/api/user/avatar?orgSlug=:orgSlug",
|
|
},
|
|
{
|
|
source: "/team/:teamname/avatar.png",
|
|
destination: "/api/user/avatar?teamname=:teamname",
|
|
},
|
|
{
|
|
source: "/icons/sprite.svg",
|
|
destination: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/icons/sprite.svg`,
|
|
},
|
|
// for @dub/analytics, @see: https://d.to/reverse-proxy
|
|
{
|
|
source: "/_proxy/dub/track/:path",
|
|
destination: "https://api.dub.co/track/:path",
|
|
},
|
|
|
|
// When updating this also update pagesAndRewritePaths.js
|
|
...[
|
|
{
|
|
source: "/:user/avatar.png",
|
|
destination: "/api/user/avatar?username=:user",
|
|
},
|
|
],
|
|
|
|
/* TODO: have these files being served from another deployment or CDN {
|
|
source: "/embed/embed.js",
|
|
destination: process.env.NEXT_PUBLIC_EMBED_LIB_URL?,
|
|
}, */
|
|
];
|
|
|
|
if (Boolean(process.env.NEXT_PUBLIC_API_V2_URL)) {
|
|
afterFiles.push({
|
|
source: "/api/v2/:path*",
|
|
destination: `${process.env.NEXT_PUBLIC_API_V2_URL}/:path*`,
|
|
});
|
|
}
|
|
|
|
return {
|
|
beforeFiles,
|
|
afterFiles,
|
|
};
|
|
},
|
|
async headers() {
|
|
const { orgSlug } = nextJsOrgRewriteConfig;
|
|
// This header can be set safely as it ensures the browser will load the resources even when COEP is set.
|
|
// But this header must be set only on those resources that are safe to be loaded in a cross-origin context e.g. all embeddable pages's resources
|
|
const CORP_CROSS_ORIGIN_HEADER = {
|
|
key: "Cross-Origin-Resource-Policy",
|
|
value: "cross-origin",
|
|
};
|
|
|
|
const ACCESS_CONTROL_ALLOW_ORIGIN_HEADER = {
|
|
key: "Access-Control-Allow-Origin",
|
|
value: "*",
|
|
};
|
|
|
|
return [
|
|
{
|
|
source: "/auth/:path*",
|
|
headers: [
|
|
{
|
|
key: "X-Frame-Options",
|
|
value: "DENY",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
source: "/signup",
|
|
headers: [
|
|
{
|
|
key: "X-Frame-Options",
|
|
value: "DENY",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
source: "/:path*",
|
|
headers: [
|
|
{
|
|
key: "X-Content-Type-Options",
|
|
value: "nosniff",
|
|
},
|
|
{
|
|
key: "Referrer-Policy",
|
|
value: "strict-origin-when-cross-origin",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
source: "/embed/embed.js",
|
|
headers: [CORP_CROSS_ORIGIN_HEADER],
|
|
},
|
|
{
|
|
source: "/:path*/embed",
|
|
// COEP require-corp header is set conditionally when flag.coep is set to true
|
|
headers: [CORP_CROSS_ORIGIN_HEADER],
|
|
},
|
|
{
|
|
source: "/:path*",
|
|
has: [
|
|
{
|
|
type: "host",
|
|
value: "cal.com",
|
|
},
|
|
],
|
|
headers: [
|
|
// make sure to pass full referer URL for booking pages
|
|
{
|
|
key: "Referrer-Policy",
|
|
value: "no-referrer-when-downgrade",
|
|
},
|
|
],
|
|
},
|
|
// These resources loads through embed as well, so they need to have CORP_CROSS_ORIGIN_HEADER
|
|
...[
|
|
{
|
|
source: "/api/avatar/:path*",
|
|
headers: [CORP_CROSS_ORIGIN_HEADER],
|
|
},
|
|
{
|
|
source: "/avatar.svg",
|
|
headers: [CORP_CROSS_ORIGIN_HEADER],
|
|
},
|
|
{
|
|
source: "/icons/sprite.svg(\\?v=[0-9a-zA-Z\\-\\.]+)?",
|
|
headers: [
|
|
CORP_CROSS_ORIGIN_HEADER,
|
|
ACCESS_CONTROL_ALLOW_ORIGIN_HEADER,
|
|
{
|
|
key: "Cache-Control",
|
|
value: "public, max-age=31536000, immutable",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
...(isOrganizationsEnabled
|
|
? [
|
|
orgDomainMatcherConfig.root
|
|
? {
|
|
...orgDomainMatcherConfig.root,
|
|
headers: [
|
|
{
|
|
key: "X-Cal-Org-path",
|
|
value: `/team/${orgSlug}`,
|
|
},
|
|
],
|
|
}
|
|
: null,
|
|
{
|
|
...orgDomainMatcherConfig.user,
|
|
headers: [
|
|
{
|
|
key: "X-Cal-Org-path",
|
|
value: `/org/${orgSlug}/:user`,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
...orgDomainMatcherConfig.userType,
|
|
headers: [
|
|
{
|
|
key: "X-Cal-Org-path",
|
|
value: `/org/${orgSlug}/:user/:type`,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
...orgDomainMatcherConfig.userTypeEmbed,
|
|
headers: [
|
|
{
|
|
key: "X-Cal-Org-path",
|
|
value: `/org/${orgSlug}/:user/:type/embed`,
|
|
},
|
|
],
|
|
},
|
|
]
|
|
: []),
|
|
].filter(Boolean);
|
|
},
|
|
async redirects() {
|
|
const redirects = [
|
|
{
|
|
source: "/settings/organizations",
|
|
destination: "/settings/organizations/profile",
|
|
permanent: false,
|
|
},
|
|
{
|
|
source: "/apps/routing-forms",
|
|
destination: "/routing/forms",
|
|
permanent: false,
|
|
},
|
|
{
|
|
source: "/api/app-store/:path*",
|
|
destination: "/app-store/:path*",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/auth/signup",
|
|
destination: "/signup",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/auth",
|
|
destination: "/auth/login",
|
|
permanent: false,
|
|
},
|
|
{
|
|
source: "/settings",
|
|
destination: "/settings/my-account/profile",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/settings/teams",
|
|
destination: "/teams",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/settings/admin",
|
|
destination: "/settings/admin/flags",
|
|
permanent: true,
|
|
},
|
|
/* V2 testers get redirected to the new settings */
|
|
{
|
|
source: "/settings/profile",
|
|
destination: "/settings/my-account/profile",
|
|
permanent: false,
|
|
},
|
|
{
|
|
source: "/settings/security",
|
|
destination: "/settings/security/password",
|
|
permanent: false,
|
|
},
|
|
{
|
|
source: "/bookings",
|
|
destination: "/bookings/upcoming",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/call/:path*",
|
|
destination: "/video/:path*",
|
|
permanent: false,
|
|
},
|
|
/* Attempt to mitigate DDoS attack */
|
|
{
|
|
source: "/api/auth/:path*",
|
|
has: [
|
|
{
|
|
type: "query",
|
|
key: "callbackUrl",
|
|
// prettier-ignore
|
|
value: "^(?!https?:\/\/).*$",
|
|
},
|
|
],
|
|
destination: "/404",
|
|
permanent: false,
|
|
},
|
|
{
|
|
source: "/booking/direct/:action/:email/:bookingUid/:oldToken",
|
|
destination: "/api/link?action=:action&email=:email&bookingUid=:bookingUid&oldToken=:oldToken",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/support",
|
|
missing: [
|
|
{
|
|
type: "header",
|
|
key: "host",
|
|
value: nextJsOrgRewriteConfig.orgHostPath,
|
|
},
|
|
],
|
|
destination: "/event-types?openPlain=true",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/apps/categories/video",
|
|
destination: "/apps/categories/conferencing",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/apps/installed/video",
|
|
destination: "/apps/installed/conferencing",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/apps/installed",
|
|
destination: "/apps/installed/calendar",
|
|
permanent: true,
|
|
},
|
|
{
|
|
source: "/settings/organizations/platform/:path*",
|
|
destination: "/settings/platform",
|
|
permanent: true,
|
|
},
|
|
// OAuth callbacks when sent to localhost:3000(w would be expected) should be redirected to corresponding to WEBAPP_URL
|
|
...(process.env.NODE_ENV === "development" &&
|
|
// Safer to enable the redirect only when the user is opting to test out organizations
|
|
isOrganizationsEnabled &&
|
|
// Prevent infinite redirect by checking that we aren't already on localhost
|
|
process.env.NEXT_PUBLIC_WEBAPP_URL !== "http://localhost:3000"
|
|
? [
|
|
{
|
|
has: [
|
|
{
|
|
type: "header",
|
|
key: "host",
|
|
value: "localhost:3000",
|
|
},
|
|
],
|
|
source: "/api/integrations/:args*",
|
|
destination: `${process.env.NEXT_PUBLIC_WEBAPP_URL}/api/integrations/:args*`,
|
|
permanent: false,
|
|
},
|
|
]
|
|
: []),
|
|
];
|
|
|
|
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;
|
|
},
|
|
};
|
|
|
|
module.exports = () => plugins.reduce((acc, next) => next(acc), nextConfig);
|