π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor next config
Abhinave220f909a002
diff --git a/apps/photos/configUtil.js b/apps/photos/configUtil.jsdeleted file mode 100644index 679a92f30b..0000000000--- a/apps/photos/configUtil.js+++ /dev/null@@ -1,52 +0,0 @@-const cp = require('child_process');-const { getIsSentryEnabled } = require('./sentryConfigUtil');--module.exports = {- WEB_SECURITY_HEADERS: {- 'Strict-Transport-Security': ' max-age=63072000',- 'X-Content-Type-Options': 'nosniff',- 'X-Download-Options': 'noopen',- 'X-Frame-Options': 'deny',- 'X-XSS-Protection': '1; mode=block',- 'Referrer-Policy': 'same-origin',- },-- CSP_DIRECTIVES: {- // self is safe enough- 'default-src': "'self'",- // data to allow two factor qr code- 'img-src': "'self' blob: data: https://*.openstreetmap.org",- 'media-src': "'self' blob:",- 'manifest-src': "'self'",- 'style-src': "'self' 'unsafe-inline'",- 'font-src ': "'self'; script-src 'self' 'unsafe-eval' blob:",- 'connect-src':- "'self' https://*.ente.io http://localhost:8080 data: blob: https://ente-prod-eu.s3.eu-central-003.backblazeb2.com https://ente-prod-v3.s3.eu-central-2.wasabisys.com/ https://ente-staging-eu.s3.eu-central-003.backblazeb2.com/ ws://localhost:3000/",- 'base-uri ': "'self'",- // to allow worker- 'child-src': "'self' blob:",- 'object-src': "'none'",- 'frame-ancestors': " 'none'",- 'form-action': "'none'",- 'report-uri': ' https://csp-reporter.ente.io/local',- 'report-to': ' https://csp-reporter.ente.io/local',- },-- ALL_ROUTES: '/(.*)',-- buildCSPHeader: (directives) => ({- 'Content-Security-Policy-Report-Only': Object.entries(- directives- ).reduce((acc, [key, value]) => acc + `${key} ${value};`, ''),- }),-- convertToNextHeaderFormat: (headers) =>- Object.entries(headers).map(([key, value]) => ({ key, value })),-- getGitSha: () =>- cp.execSync('git rev-parse --short HEAD', {- cwd: __dirname,- encoding: 'utf8',- }),- getIsSentryEnabled: getIsSentryEnabled,-};diff --git a/apps/photos/next.config.js b/apps/photos/next.config.jsindex 3d4340556e..d09487bad1 100644--- a/apps/photos/next.config.js+++ b/apps/photos/next.config.js@@ -1,84 +1,3 @@-const withBundleAnalyzer = require('@next/bundle-analyzer')({- enabled: process.env.ANALYZE === 'true',-});+const nextConfigBase = require('@ente/shared/next/next.config.base.js');-const { withSentryConfig } = require('@sentry/nextjs');-const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');--const {- getGitSha,- convertToNextHeaderFormat,- buildCSPHeader,- WEB_SECURITY_HEADERS,- CSP_DIRECTIVES,- ALL_ROUTES,- getIsSentryEnabled,-} = require('./configUtil');--const GIT_SHA = getGitSha();--const IS_SENTRY_ENABLED = getIsSentryEnabled();--module.exports = (phase) =>- withSentryConfig(- withBundleAnalyzer({- sentry: {- hideSourceMaps: false,- widenClientFileUpload: true,- },- compiler: {- emotion: {- importMap: {- '@mui/material': {- styled: {- canonicalImport: ['@emotion/styled', 'default'],- styledBaseImport: ['@mui/material', 'styled'],- },- },- '@mui/material/styles': {- styled: {- canonicalImport: ['@emotion/styled', 'default'],- styledBaseImport: [- '@mui/material/styles',- 'styled',- ],- },- },- },- },- },- transpilePackages: [- '@mui/material',- '@mui/system',- '@mui/icons-material',- ],- env: {- SENTRY_RELEASE: GIT_SHA,- NEXT_PUBLIC_IS_TEST_APP: process.env.IS_TEST_RELEASE,- },-- headers() {- return [- {- // Apply these headers to all routes in your application....- source: ALL_ROUTES,- headers: convertToNextHeaderFormat({- ...WEB_SECURITY_HEADERS,- ...buildCSPHeader(CSP_DIRECTIVES),- }),- },- ];- },- // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j- webpack: (config, { isServer }) => {- if (!isServer) {- config.resolve.fallback.fs = false;- }- return config;- },- }),- {- release: GIT_SHA,- dryRun: phase === PHASE_DEVELOPMENT_SERVER || !IS_SENTRY_ENABLED,- }- );+module.exports = nextConfigBase;diff --git a/packages/shared/next/next.config.base.js b/packages/shared/next/next.config.base.jsindex 7f3def142b..f80b3592a0 100644--- a/packages/shared/next/next.config.base.js+++ b/packages/shared/next/next.config.base.js@@ -67,6 +67,12 @@ module.exports = (phase) =>},];},+ webpack: (config, { isServer }) => {+ if (!isServer) {+ config.resolve.fallback.fs = false;+ }+ return config;+ },},{dryRun: phase === PHASE_DEVELOPMENT_SERVER || !IS_SENTRY_ENABLED,