settings.defaults.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. const fs = require('fs')
  2. const Path = require('path')
  3. const { merge } = require('@overleaf/settings/merge')
  4. // Automatically detect module imports that are included in this version of the application (SaaS, Server-CE, Server Pro).
  5. // E.g. during a Server-CE build, we will not find imports for proprietary modules.
  6. //
  7. // Restart webpack after adding/removing modules.
  8. const MODULES_PATH = Path.join(__dirname, '../modules')
  9. const entryPointsIde = []
  10. const entryPointsMain = []
  11. fs.readdirSync(MODULES_PATH).forEach(module => {
  12. const entryPathIde = Path.join(
  13. MODULES_PATH,
  14. module,
  15. '/frontend/js/ide/index.js'
  16. )
  17. if (fs.existsSync(entryPathIde)) {
  18. entryPointsIde.push(entryPathIde)
  19. }
  20. const entryPathMain = Path.join(
  21. MODULES_PATH,
  22. module,
  23. '/frontend/js/main/index.js'
  24. )
  25. if (fs.existsSync(entryPathMain)) {
  26. entryPointsMain.push(entryPathMain)
  27. }
  28. })
  29. let defaultFeatures, siteUrl
  30. // Make time interval config easier.
  31. const seconds = 1000
  32. const minutes = 60 * seconds
  33. // These credentials are used for authenticating api requests
  34. // between services that may need to go over public channels
  35. const httpAuthUser = process.env.WEB_API_USER
  36. const httpAuthPass = process.env.WEB_API_PASSWORD
  37. const httpAuthUsers = {}
  38. if (httpAuthUser && httpAuthPass) {
  39. httpAuthUsers[httpAuthUser] = httpAuthPass
  40. }
  41. const sessionSecret = process.env.SESSION_SECRET || 'secret-please-change'
  42. const intFromEnv = function (name, defaultValue) {
  43. if (
  44. [null, undefined].includes(defaultValue) ||
  45. typeof defaultValue !== 'number'
  46. ) {
  47. throw new Error(
  48. `Bad default integer value for setting: ${name}, ${defaultValue}`
  49. )
  50. }
  51. return parseInt(process.env[name], 10) || defaultValue
  52. }
  53. const defaultTextExtensions = [
  54. 'tex',
  55. 'latex',
  56. 'sty',
  57. 'cls',
  58. 'bst',
  59. 'bib',
  60. 'bibtex',
  61. 'txt',
  62. 'tikz',
  63. 'mtx',
  64. 'rtex',
  65. 'md',
  66. 'asy',
  67. 'lbx',
  68. 'bbx',
  69. 'cbx',
  70. 'm',
  71. 'lco',
  72. 'dtx',
  73. 'ins',
  74. 'ist',
  75. 'def',
  76. 'clo',
  77. 'ldf',
  78. 'rmd',
  79. 'lua',
  80. 'gv',
  81. 'mf',
  82. 'yml',
  83. 'yaml',
  84. 'lhs',
  85. 'mk',
  86. 'xmpdata',
  87. 'cfg',
  88. 'rnw',
  89. 'ltx',
  90. 'inc',
  91. ]
  92. const parseTextExtensions = function (extensions) {
  93. if (extensions) {
  94. return extensions.split(',').map(ext => ext.trim())
  95. } else {
  96. return []
  97. }
  98. }
  99. const httpPermissionsPolicy = {
  100. blocked: [
  101. 'accelerometer',
  102. 'attribution-reporting',
  103. 'browsing-topics',
  104. 'camera',
  105. 'display-capture',
  106. 'encrypted-media',
  107. 'fullscreen',
  108. 'gamepad',
  109. 'geolocation',
  110. 'gyroscope',
  111. 'hid',
  112. 'identity-credentials-get',
  113. 'idle-detection',
  114. 'local-fonts',
  115. 'magnetometer',
  116. 'microphone',
  117. 'midi',
  118. 'otp-credentials',
  119. 'payment',
  120. 'picture-in-picture',
  121. 'screen-wake-lock',
  122. 'serial',
  123. 'storage-access',
  124. 'usb',
  125. 'window-management',
  126. 'xr-spatial-tracking',
  127. ],
  128. allowed: {
  129. autoplay: 'self "https://videos.ctfassets.net"',
  130. },
  131. }
  132. module.exports = {
  133. env: 'server-ce',
  134. limits: {
  135. httpGlobalAgentMaxSockets: 300,
  136. httpsGlobalAgentMaxSockets: 300,
  137. },
  138. allowAnonymousReadAndWriteSharing:
  139. process.env.OVERLEAF_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING === 'true',
  140. // Databases
  141. // ---------
  142. mongo: {
  143. options: {
  144. appname: 'web',
  145. maxPoolSize: parseInt(process.env.MONGO_POOL_SIZE, 10) || 100,
  146. serverSelectionTimeoutMS:
  147. parseInt(process.env.MONGO_SERVER_SELECTION_TIMEOUT, 10) || 60000,
  148. // Setting socketTimeoutMS to 0 means no timeout
  149. socketTimeoutMS: parseInt(
  150. process.env.MONGO_SOCKET_TIMEOUT ?? '60000',
  151. 10
  152. ),
  153. monitorCommands: true,
  154. },
  155. url:
  156. process.env.MONGO_CONNECTION_STRING ||
  157. process.env.MONGO_URL ||
  158. `mongodb://${process.env.MONGO_HOST || '127.0.0.1'}/sharelatex`,
  159. hasSecondaries: process.env.MONGO_HAS_SECONDARIES === 'true',
  160. },
  161. redis: {
  162. web: {
  163. host: process.env.REDIS_HOST || '127.0.0.1',
  164. port: process.env.REDIS_PORT || '6379',
  165. password: process.env.REDIS_PASSWORD || '',
  166. db: process.env.REDIS_DB,
  167. maxRetriesPerRequest: parseInt(
  168. process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
  169. ),
  170. },
  171. // websessions:
  172. // cluster: [
  173. // {host: '127.0.0.1', port: 7000}
  174. // {host: '127.0.0.1', port: 7001}
  175. // {host: '127.0.0.1', port: 7002}
  176. // {host: '127.0.0.1', port: 7003}
  177. // {host: '127.0.0.1', port: 7004}
  178. // {host: '127.0.0.1', port: 7005}
  179. // ]
  180. // ratelimiter:
  181. // cluster: [
  182. // {host: '127.0.0.1', port: 7000}
  183. // {host: '127.0.0.1', port: 7001}
  184. // {host: '127.0.0.1', port: 7002}
  185. // {host: '127.0.0.1', port: 7003}
  186. // {host: '127.0.0.1', port: 7004}
  187. // {host: '127.0.0.1', port: 7005}
  188. // ]
  189. // cooldown:
  190. // cluster: [
  191. // {host: '127.0.0.1', port: 7000}
  192. // {host: '127.0.0.1', port: 7001}
  193. // {host: '127.0.0.1', port: 7002}
  194. // {host: '127.0.0.1', port: 7003}
  195. // {host: '127.0.0.1', port: 7004}
  196. // {host: '127.0.0.1', port: 7005}
  197. // ]
  198. api: {
  199. host: process.env.REDIS_HOST || '127.0.0.1',
  200. port: process.env.REDIS_PORT || '6379',
  201. password: process.env.REDIS_PASSWORD || '',
  202. maxRetriesPerRequest: parseInt(
  203. process.env.REDIS_MAX_RETRIES_PER_REQUEST || '20'
  204. ),
  205. },
  206. },
  207. // Service locations
  208. // -----------------
  209. // Configure which ports to run each service on. Generally you
  210. // can leave these as they are unless you have some other services
  211. // running which conflict, or want to run the web process on port 80.
  212. internal: {
  213. web: {
  214. port: process.env.WEB_PORT || 3000,
  215. host: process.env.LISTEN_ADDRESS || '127.0.0.1',
  216. },
  217. },
  218. // Tell each service where to find the other services. If everything
  219. // is running locally then this is easy, but they exist as separate config
  220. // options incase you want to run some services on remote hosts.
  221. apis: {
  222. web: {
  223. url: `http://${
  224. process.env.WEB_API_HOST || process.env.WEB_HOST || '127.0.0.1'
  225. }:${process.env.WEB_API_PORT || process.env.WEB_PORT || 3000}`,
  226. user: httpAuthUser,
  227. pass: httpAuthPass,
  228. },
  229. documentupdater: {
  230. url: `http://${
  231. process.env.DOCUPDATER_HOST ||
  232. process.env.DOCUMENT_UPDATER_HOST ||
  233. '127.0.0.1'
  234. }:3003`,
  235. },
  236. spelling: {
  237. url: `http://${process.env.SPELLING_HOST || '127.0.0.1'}:3005`,
  238. host: process.env.SPELLING_HOST,
  239. },
  240. docstore: {
  241. url: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`,
  242. pubUrl: `http://${process.env.DOCSTORE_HOST || '127.0.0.1'}:3016`,
  243. },
  244. chat: {
  245. internal_url: `http://${process.env.CHAT_HOST || '127.0.0.1'}:3010`,
  246. },
  247. filestore: {
  248. url: `http://${process.env.FILESTORE_HOST || '127.0.0.1'}:3009`,
  249. },
  250. clsi: {
  251. url: `http://${process.env.CLSI_HOST || '127.0.0.1'}:3013`,
  252. // url: "http://#{process.env['CLSI_LB_HOST']}:3014"
  253. backendGroupName: undefined,
  254. submissionBackendClass:
  255. process.env.CLSI_SUBMISSION_BACKEND_CLASS || 'n2d',
  256. },
  257. project_history: {
  258. sendProjectStructureOps: true,
  259. url: `http://${process.env.PROJECT_HISTORY_HOST || '127.0.0.1'}:3054`,
  260. },
  261. realTime: {
  262. url: `http://${process.env.REALTIME_HOST || '127.0.0.1'}:3026`,
  263. },
  264. contacts: {
  265. url: `http://${process.env.CONTACTS_HOST || '127.0.0.1'}:3036`,
  266. },
  267. notifications: {
  268. url: `http://${process.env.NOTIFICATIONS_HOST || '127.0.0.1'}:3042`,
  269. },
  270. webpack: {
  271. url: `http://${process.env.WEBPACK_HOST || '127.0.0.1'}:3808`,
  272. },
  273. wiki: {
  274. url: process.env.WIKI_URL || 'https://learn.sharelatex.com',
  275. maxCacheAge: parseInt(process.env.WIKI_MAX_CACHE_AGE || 5 * minutes, 10),
  276. },
  277. haveIBeenPwned: {
  278. enabled: process.env.HAVE_I_BEEN_PWNED_ENABLED === 'true',
  279. url:
  280. process.env.HAVE_I_BEEN_PWNED_URL || 'https://api.pwnedpasswords.com',
  281. timeout: parseInt(process.env.HAVE_I_BEEN_PWNED_TIMEOUT, 10) || 5 * 1000,
  282. },
  283. // For legacy reasons, we need to populate the below objects.
  284. v1: {},
  285. recurly: {},
  286. },
  287. // Defines which features are allowed in the
  288. // Permissions-Policy HTTP header
  289. httpPermissions: httpPermissionsPolicy,
  290. useHttpPermissionsPolicy: true,
  291. jwt: {
  292. key: process.env.OT_JWT_AUTH_KEY,
  293. algorithm: process.env.OT_JWT_AUTH_ALG || 'HS256',
  294. },
  295. splitTest: {
  296. devToolbar: {
  297. enabled: false,
  298. },
  299. },
  300. splitTests: [],
  301. // Where your instance of Overleaf Community Edition/Server Pro can be found publicly. Used in emails
  302. // that are sent out, generated links, etc.
  303. siteUrl: (siteUrl = process.env.PUBLIC_URL || 'http://127.0.0.1:3000'),
  304. lockManager: {
  305. lockTestInterval: intFromEnv('LOCK_MANAGER_LOCK_TEST_INTERVAL', 50),
  306. maxTestInterval: intFromEnv('LOCK_MANAGER_MAX_TEST_INTERVAL', 1000),
  307. maxLockWaitTime: intFromEnv('LOCK_MANAGER_MAX_LOCK_WAIT_TIME', 10000),
  308. redisLockExpiry: intFromEnv('LOCK_MANAGER_REDIS_LOCK_EXPIRY', 30),
  309. slowExecutionThreshold: intFromEnv(
  310. 'LOCK_MANAGER_SLOW_EXECUTION_THRESHOLD',
  311. 5000
  312. ),
  313. },
  314. // Optional separate location for websocket connections, if unset defaults to siteUrl.
  315. wsUrl: process.env.WEBSOCKET_URL,
  316. wsUrlV2: process.env.WEBSOCKET_URL_V2,
  317. wsUrlBeta: process.env.WEBSOCKET_URL_BETA,
  318. wsUrlV2Percentage: parseInt(
  319. process.env.WEBSOCKET_URL_V2_PERCENTAGE || '0',
  320. 10
  321. ),
  322. wsRetryHandshake: parseInt(process.env.WEBSOCKET_RETRY_HANDSHAKE || '5', 10),
  323. // cookie domain
  324. // use full domain for cookies to only be accessible from that domain,
  325. // replace subdomain with dot to have them accessible on all subdomains
  326. cookieDomain: process.env.COOKIE_DOMAIN,
  327. cookieName: process.env.COOKIE_NAME || 'overleaf.sid',
  328. cookieRollingSession: true,
  329. // this is only used if cookies are used for clsi backend
  330. // clsiCookieKey: "clsiserver"
  331. robotsNoindex: process.env.ROBOTS_NOINDEX === 'true' || false,
  332. maxEntitiesPerProject: parseInt(
  333. process.env.MAX_ENTITIES_PER_PROJECT || '2000',
  334. 10
  335. ),
  336. projectUploadTimeout: parseInt(
  337. process.env.PROJECT_UPLOAD_TIMEOUT || '120000',
  338. 10
  339. ),
  340. maxUploadSize: 50 * 1024 * 1024, // 50 MB
  341. multerOptions: {
  342. preservePath: process.env.MULTER_PRESERVE_PATH,
  343. },
  344. // start failing the health check if active handles exceeds this limit
  345. maxActiveHandles: process.env.MAX_ACTIVE_HANDLES
  346. ? parseInt(process.env.MAX_ACTIVE_HANDLES, 10)
  347. : undefined,
  348. // Security
  349. // --------
  350. security: {
  351. sessionSecret,
  352. bcryptRounds: parseInt(process.env.BCRYPT_ROUNDS, 10) || 12,
  353. }, // number of rounds used to hash user passwords (raised to power 2)
  354. adminUrl: process.env.ADMIN_URL,
  355. adminOnlyLogin: process.env.ADMIN_ONLY_LOGIN === 'true',
  356. adminPrivilegeAvailable: process.env.ADMIN_PRIVILEGE_AVAILABLE === 'true',
  357. blockCrossOriginRequests: process.env.BLOCK_CROSS_ORIGIN_REQUESTS === 'true',
  358. allowedOrigins: (process.env.ALLOWED_ORIGINS || siteUrl).split(','),
  359. httpAuthUsers,
  360. // Default features
  361. // ----------------
  362. //
  363. // You can select the features that are enabled by default for new
  364. // new users.
  365. defaultFeatures: (defaultFeatures = {
  366. collaborators: -1,
  367. dropbox: true,
  368. github: true,
  369. gitBridge: true,
  370. versioning: true,
  371. compileTimeout: 180,
  372. compileGroup: 'standard',
  373. references: true,
  374. templates: true,
  375. trackChanges: true,
  376. }),
  377. // featuresEpoch: 'YYYY-MM-DD',
  378. features: {
  379. personal: defaultFeatures,
  380. },
  381. groupPlanModalOptions: {
  382. plan_codes: [],
  383. currencies: [],
  384. sizes: [],
  385. usages: [],
  386. },
  387. plans: [
  388. {
  389. planCode: 'personal',
  390. name: 'Personal',
  391. price_in_cents: 0,
  392. features: defaultFeatures,
  393. },
  394. ],
  395. enableSubscriptions: false,
  396. restrictedCountries: [],
  397. enableOnboardingEmails: process.env.ENABLE_ONBOARDING_EMAILS === 'true',
  398. enabledLinkedFileTypes: (process.env.ENABLED_LINKED_FILE_TYPES || '').split(
  399. ','
  400. ),
  401. // i18n
  402. // ------
  403. //
  404. i18n: {
  405. checkForHTMLInVars: process.env.I18N_CHECK_FOR_HTML_IN_VARS === 'true',
  406. escapeHTMLInVars: process.env.I18N_ESCAPE_HTML_IN_VARS === 'true',
  407. subdomainLang: {
  408. www: { lngCode: 'en', url: siteUrl },
  409. },
  410. defaultLng: 'en',
  411. },
  412. // Spelling languages
  413. // ------------------
  414. //
  415. // You must have the corresponding aspell package installed to
  416. // be able to use a language.
  417. languages: [
  418. { code: 'en', name: 'English' },
  419. { code: 'en_US', name: 'English (American)' },
  420. { code: 'en_GB', name: 'English (British)' },
  421. { code: 'en_CA', name: 'English (Canadian)' },
  422. { code: 'af', name: 'Afrikaans' },
  423. { code: 'ar', name: 'Arabic' },
  424. { code: 'gl', name: 'Galician' },
  425. { code: 'eu', name: 'Basque' },
  426. { code: 'br', name: 'Breton' },
  427. { code: 'bg', name: 'Bulgarian' },
  428. { code: 'ca', name: 'Catalan' },
  429. { code: 'hr', name: 'Croatian' },
  430. { code: 'cs', name: 'Czech' },
  431. { code: 'da', name: 'Danish' },
  432. { code: 'nl', name: 'Dutch' },
  433. { code: 'eo', name: 'Esperanto' },
  434. { code: 'et', name: 'Estonian' },
  435. { code: 'fo', name: 'Faroese' },
  436. { code: 'fr', name: 'French' },
  437. { code: 'de', name: 'German' },
  438. { code: 'el', name: 'Greek' },
  439. { code: 'id', name: 'Indonesian' },
  440. { code: 'ga', name: 'Irish' },
  441. { code: 'it', name: 'Italian' },
  442. { code: 'kk', name: 'Kazakh' },
  443. { code: 'ku', name: 'Kurdish' },
  444. { code: 'lv', name: 'Latvian' },
  445. { code: 'lt', name: 'Lithuanian' },
  446. { code: 'nr', name: 'Ndebele' },
  447. { code: 'ns', name: 'Northern Sotho' },
  448. { code: 'no', name: 'Norwegian' },
  449. { code: 'fa', name: 'Persian' },
  450. { code: 'pl', name: 'Polish' },
  451. { code: 'pt_BR', name: 'Portuguese (Brazilian)' },
  452. { code: 'pt_PT', name: 'Portuguese (European)' },
  453. { code: 'pa', name: 'Punjabi' },
  454. { code: 'ro', name: 'Romanian' },
  455. { code: 'ru', name: 'Russian' },
  456. { code: 'sk', name: 'Slovak' },
  457. { code: 'sl', name: 'Slovenian' },
  458. { code: 'st', name: 'Southern Sotho' },
  459. { code: 'es', name: 'Spanish' },
  460. { code: 'sv', name: 'Swedish' },
  461. { code: 'tl', name: 'Tagalog' },
  462. { code: 'ts', name: 'Tsonga' },
  463. { code: 'tn', name: 'Tswana' },
  464. { code: 'hsb', name: 'Upper Sorbian' },
  465. { code: 'cy', name: 'Welsh' },
  466. { code: 'xh', name: 'Xhosa' },
  467. ],
  468. translatedLanguages: {
  469. cn: '简体中文',
  470. cs: 'Čeština',
  471. da: 'Dansk',
  472. de: 'Deutsch',
  473. en: 'English',
  474. es: 'Español',
  475. fi: 'Suomi',
  476. fr: 'Français',
  477. it: 'Italiano',
  478. ja: '日本語',
  479. ko: '한국어',
  480. nl: 'Nederlands',
  481. no: 'Norsk',
  482. pl: 'Polski',
  483. pt: 'Português',
  484. ro: 'Română',
  485. ru: 'Русский',
  486. sv: 'Svenska',
  487. tr: 'Türkçe',
  488. uk: 'Українська',
  489. 'zh-CN': '简体中文',
  490. },
  491. maxDictionarySize: 1024 * 1024, // 1 MB
  492. // Password Settings
  493. // -----------
  494. // These restrict the passwords users can use when registering
  495. // opts are from http://antelle.github.io/passfield
  496. passwordStrengthOptions: {
  497. length: {
  498. min: 8,
  499. // Bcrypt does not support longer passwords than that.
  500. max: 72,
  501. },
  502. },
  503. elevateAccountSecurityAfterFailedLogin:
  504. parseInt(process.env.ELEVATED_ACCOUNT_SECURITY_AFTER_FAILED_LOGIN_MS, 10) ||
  505. 24 * 60 * 60 * 1000,
  506. deviceHistory: {
  507. cookieName: process.env.DEVICE_HISTORY_COOKIE_NAME || 'deviceHistory',
  508. entryExpiry:
  509. parseInt(process.env.DEVICE_HISTORY_ENTRY_EXPIRY_MS, 10) ||
  510. 90 * 24 * 60 * 60 * 1000,
  511. maxEntries: parseInt(process.env.DEVICE_HISTORY_MAX_ENTRIES, 10) || 10,
  512. secret: process.env.DEVICE_HISTORY_SECRET,
  513. },
  514. // Email support
  515. // -------------
  516. //
  517. // Overleaf uses nodemailer (http://www.nodemailer.com/) to send transactional emails.
  518. // To see the range of transport and options they support, see http://www.nodemailer.com/docs/transports
  519. // email:
  520. // fromAddress: ""
  521. // replyTo: ""
  522. // lifecycle: false
  523. // # Example transport and parameter settings for Amazon SES
  524. // transport: "SES"
  525. // parameters:
  526. // AWSAccessKeyID: ""
  527. // AWSSecretKey: ""
  528. // For legacy reasons, we need to populate this object.
  529. sentry: {},
  530. // Production Settings
  531. // -------------------
  532. debugPugTemplates: process.env.DEBUG_PUG_TEMPLATES === 'true',
  533. precompilePugTemplatesAtBootTime: process.env
  534. .PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME
  535. ? process.env.PRECOMPILE_PUG_TEMPLATES_AT_BOOT_TIME === 'true'
  536. : process.env.NODE_ENV === 'production',
  537. // Should javascript assets be served minified or not.
  538. useMinifiedJs: process.env.MINIFIED_JS === 'true' || false,
  539. // Should static assets be sent with a header to tell the browser to cache
  540. // them.
  541. cacheStaticAssets: false,
  542. // If you are running Overleaf over https, set this to true to send the
  543. // cookie with a secure flag (recommended).
  544. secureCookie: false,
  545. // 'SameSite' cookie setting. Can be set to 'lax', 'none' or 'strict'
  546. // 'lax' is recommended, as 'strict' will prevent people linking to projects
  547. // https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
  548. sameSiteCookie: 'lax',
  549. // If you are running Overleaf behind a proxy (like Apache, Nginx, etc)
  550. // then set this to true to allow it to correctly detect the forwarded IP
  551. // address and http/https protocol information.
  552. behindProxy: false,
  553. // Delay before closing the http server upon receiving a SIGTERM process signal.
  554. gracefulShutdownDelayInMs:
  555. parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '5', 10) * seconds,
  556. // Expose the hostname in the `X-Served-By` response header
  557. exposeHostname: process.env.EXPOSE_HOSTNAME === 'true',
  558. // Cookie max age (in milliseconds). Set to false for a browser session.
  559. cookieSessionLength: 5 * 24 * 60 * 60 * 1000, // 5 days
  560. // When true, only allow invites to be sent to email addresses that
  561. // already have user accounts
  562. restrictInvitesToExistingAccounts: false,
  563. // Should we allow access to any page without logging in? This includes
  564. // public projects, /learn, /templates, about pages, etc.
  565. allowPublicAccess: process.env.OVERLEAF_ALLOW_PUBLIC_ACCESS === 'true',
  566. // editor should be open by default
  567. editorIsOpen: process.env.EDITOR_OPEN !== 'false',
  568. // site should be open by default
  569. siteIsOpen: process.env.SITE_OPEN !== 'false',
  570. // status file for closing/opening the site at run-time, polled every 5s
  571. siteMaintenanceFile: process.env.SITE_MAINTENANCE_FILE,
  572. // Use a single compile directory for all users in a project
  573. // (otherwise each user has their own directory)
  574. // disablePerUserCompiles: true
  575. // Domain the client (pdfjs) should download the compiled pdf from
  576. pdfDownloadDomain: process.env.COMPILES_USER_CONTENT_DOMAIN, // "http://clsi-lb:3014"
  577. // By default turn on feature flag, can be overridden per request.
  578. enablePdfCaching: process.env.ENABLE_PDF_CACHING === 'true',
  579. // Maximum size of text documents in the real-time editing system.
  580. max_doc_length: 2 * 1024 * 1024, // 2mb
  581. primary_email_check_expiration: 1000 * 60 * 60 * 24 * 90, // 90 days
  582. // Maximum JSON size in HTTP requests
  583. // We should be able to process twice the max doc length, to allow for
  584. // - the doc content
  585. // - text ranges spanning the whole doc
  586. //
  587. // There's also overhead required for the JSON encoding and the UTF-8 encoding,
  588. // theoretically up to 3 times the max doc length. On the other hand, we don't
  589. // want to block the event loop with JSON parsing, so we try to find a
  590. // practical compromise.
  591. max_json_request_size:
  592. parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB
  593. // Internal configs
  594. // ----------------
  595. path: {
  596. // If we ever need to write something to disk (e.g. incoming requests
  597. // that need processing but may be too big for memory, then write
  598. // them to disk here).
  599. dumpFolder: Path.resolve(__dirname, '../data/dumpFolder'),
  600. uploadFolder: Path.resolve(__dirname, '../data/uploads'),
  601. },
  602. // Automatic Snapshots
  603. // -------------------
  604. automaticSnapshots: {
  605. // How long should we wait after the user last edited to
  606. // take a snapshot?
  607. waitTimeAfterLastEdit: 5 * minutes,
  608. // Even if edits are still taking place, this is maximum
  609. // time to wait before taking another snapshot.
  610. maxTimeBetweenSnapshots: 30 * minutes,
  611. },
  612. // Smoke test
  613. // ----------
  614. // Provide log in credentials and a project to be able to run
  615. // some basic smoke tests to check the core functionality.
  616. //
  617. smokeTest: {
  618. user: process.env.SMOKE_TEST_USER,
  619. userId: process.env.SMOKE_TEST_USER_ID,
  620. password: process.env.SMOKE_TEST_PASSWORD,
  621. projectId: process.env.SMOKE_TEST_PROJECT_ID,
  622. rateLimitSubject: process.env.SMOKE_TEST_RATE_LIMIT_SUBJECT || '127.0.0.1',
  623. stepTimeout: parseInt(process.env.SMOKE_TEST_STEP_TIMEOUT || '10000', 10),
  624. },
  625. appName: process.env.APP_NAME || 'Overleaf (Community Edition)',
  626. adminEmail: process.env.ADMIN_EMAIL || 'placeholder@example.com',
  627. adminDomains: process.env.ADMIN_DOMAINS
  628. ? JSON.parse(process.env.ADMIN_DOMAINS)
  629. : undefined,
  630. nav: {
  631. title: process.env.APP_NAME || 'Overleaf Community Edition',
  632. hide_powered_by: process.env.NAV_HIDE_POWERED_BY === 'true',
  633. left_footer: [],
  634. right_footer: [
  635. {
  636. text: "<i class='fa fa-github-square'></i> Fork on GitHub!",
  637. url: 'https://github.com/overleaf/overleaf',
  638. },
  639. ],
  640. showSubscriptionLink: false,
  641. header_extras: [],
  642. },
  643. // Example:
  644. // header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
  645. recaptcha: {
  646. endpoint:
  647. process.env.RECAPTCHA_ENDPOINT ||
  648. 'https://www.google.com/recaptcha/api/siteverify',
  649. trustedUsers: (process.env.CAPTCHA_TRUSTED_USERS || '')
  650. .split(',')
  651. .map(x => x.trim())
  652. .filter(x => x !== ''),
  653. disabled: {
  654. invite: true,
  655. login: true,
  656. passwordReset: true,
  657. register: true,
  658. addEmail: true,
  659. },
  660. },
  661. customisation: {},
  662. redirects: {
  663. '/templates/index': '/templates/',
  664. },
  665. reloadModuleViewsOnEachRequest: process.env.NODE_ENV === 'development',
  666. rateLimit: {
  667. autoCompile: {
  668. everyone: process.env.RATE_LIMIT_AUTO_COMPILE_EVERYONE || 100,
  669. standard: process.env.RATE_LIMIT_AUTO_COMPILE_STANDARD || 25,
  670. },
  671. },
  672. analytics: {
  673. enabled: false,
  674. },
  675. compileBodySizeLimitMb: process.env.COMPILE_BODY_SIZE_LIMIT_MB || 7,
  676. textExtensions: defaultTextExtensions.concat(
  677. parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
  678. ),
  679. // case-insensitive file names that is editable (doc) in the editor
  680. editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
  681. fileIgnorePattern:
  682. process.env.FILE_IGNORE_PATTERN ||
  683. '**/{{__MACOSX,.git,.texpadtmp,.R}{,/**},.!(latexmkrc),*.{dvi,aux,log,toc,out,pdfsync,synctex,synctex(busy),fdb_latexmk,fls,nlo,ind,glo,gls,glg,bbl,blg,doc,docx,gz,swp}}',
  684. validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
  685. emailConfirmationDisabled:
  686. process.env.EMAIL_CONFIRMATION_DISABLED === 'true' || false,
  687. emailAddressLimit: intFromEnv('EMAIL_ADDRESS_LIMIT', 10),
  688. enabledServices: (process.env.ENABLED_SERVICES || 'web,api')
  689. .split(',')
  690. .map(s => s.trim()),
  691. // module options
  692. // ----------
  693. modules: {
  694. sanitize: {
  695. options: {
  696. allowedTags: [
  697. 'h1',
  698. 'h2',
  699. 'h3',
  700. 'h4',
  701. 'h5',
  702. 'h6',
  703. 'blockquote',
  704. 'p',
  705. 'a',
  706. 'ul',
  707. 'ol',
  708. 'nl',
  709. 'li',
  710. 'b',
  711. 'i',
  712. 'strong',
  713. 'em',
  714. 'strike',
  715. 'code',
  716. 'hr',
  717. 'br',
  718. 'div',
  719. 'table',
  720. 'thead',
  721. 'col',
  722. 'caption',
  723. 'tbody',
  724. 'tr',
  725. 'th',
  726. 'td',
  727. 'tfoot',
  728. 'pre',
  729. 'iframe',
  730. 'img',
  731. 'figure',
  732. 'figcaption',
  733. 'span',
  734. 'source',
  735. 'video',
  736. 'del',
  737. ],
  738. allowedAttributes: {
  739. a: [
  740. 'href',
  741. 'name',
  742. 'target',
  743. 'class',
  744. 'event-tracking',
  745. 'event-tracking-ga',
  746. 'event-tracking-label',
  747. 'event-tracking-trigger',
  748. ],
  749. div: ['class', 'id', 'style'],
  750. h1: ['class', 'id'],
  751. h2: ['class', 'id'],
  752. h3: ['class', 'id'],
  753. h4: ['class', 'id'],
  754. h5: ['class', 'id'],
  755. h6: ['class', 'id'],
  756. col: ['width'],
  757. figure: ['class', 'id', 'style'],
  758. figcaption: ['class', 'id', 'style'],
  759. i: ['aria-hidden', 'aria-label', 'class', 'id'],
  760. iframe: [
  761. 'allowfullscreen',
  762. 'frameborder',
  763. 'height',
  764. 'src',
  765. 'style',
  766. 'width',
  767. ],
  768. img: ['alt', 'class', 'src', 'style'],
  769. source: ['src', 'type'],
  770. span: ['class', 'id', 'style'],
  771. strong: ['style'],
  772. table: ['border', 'class', 'id', 'style'],
  773. td: ['colspan', 'rowspan', 'headers', 'style'],
  774. th: [
  775. 'abbr',
  776. 'headers',
  777. 'colspan',
  778. 'rowspan',
  779. 'scope',
  780. 'sorted',
  781. 'style',
  782. ],
  783. tr: ['class'],
  784. video: ['alt', 'class', 'controls', 'height', 'width'],
  785. },
  786. },
  787. },
  788. },
  789. overleafModuleImports: {
  790. // modules to import (an empty array for each set of modules)
  791. //
  792. // Restart webpack after making changes.
  793. //
  794. createFileModes: [],
  795. devToolbar: [],
  796. gitBridge: [],
  797. publishModal: [],
  798. tprFileViewInfo: [],
  799. tprFileViewRefreshError: [],
  800. tprFileViewRefreshButton: [],
  801. tprFileViewNotOriginalImporter: [],
  802. contactUsModal: [],
  803. editorToolbarButtons: [],
  804. sourceEditorExtensions: [],
  805. sourceEditorComponents: [],
  806. pdfLogsComponents: [],
  807. sourceEditorCompletionSources: [],
  808. sourceEditorSymbolPalette: [],
  809. sourceEditorToolbarComponents: [],
  810. writefullEditorPromotion: [],
  811. langFeedbackLinkingWidgets: [],
  812. integrationLinkingWidgets: [],
  813. referenceLinkingWidgets: [],
  814. importProjectFromGithubModalWrapper: [],
  815. importProjectFromGithubMenu: [],
  816. editorLeftMenuSync: [],
  817. editorLeftMenuManageTemplate: [],
  818. oauth2Server: [],
  819. managedGroupSubscriptionEnrollmentNotification: [],
  820. managedGroupEnrollmentInvite: [],
  821. ssoCertificateInfo: [],
  822. // See comment at the definition of these variables.
  823. entryPointsIde,
  824. entryPointsMain,
  825. },
  826. moduleImportSequence: [
  827. 'history-v1',
  828. 'launchpad',
  829. 'server-ce-scripts',
  830. 'user-activate',
  831. ],
  832. csp: {
  833. enabled: process.env.CSP_ENABLED === 'true',
  834. reportOnly: process.env.CSP_REPORT_ONLY === 'true',
  835. reportPercentage: parseFloat(process.env.CSP_REPORT_PERCENTAGE) || 0,
  836. reportUri: process.env.CSP_REPORT_URI,
  837. exclude: ['app/views/project/editor'],
  838. },
  839. unsupportedBrowsers: {
  840. ie: '<=11',
  841. safari: '<=13',
  842. },
  843. // ID of the IEEE brand in the rails app
  844. ieeeBrandId: intFromEnv('IEEE_BRAND_ID', 15),
  845. managedUsers: {
  846. enabled: false,
  847. },
  848. }
  849. module.exports.mergeWith = function (overrides) {
  850. return merge(overrides, module.exports)
  851. }