From 296011f14452b3101daa542a2998dfbd3dfd23ca Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Mon, 4 Aug 2025 17:36:02 -0400 Subject: [PATCH 1/4] chore: update buildspec and next.config for app and portal to use app-specific S3 paths - Modified buildspec.yml files to upload public assets to app-specific S3 paths, enhancing organization of static files. - Updated next.config.ts files to set assetPrefix for production to include app-specific paths, improving asset management clarity. --- apps/app/buildspec.yml | 2 +- apps/app/next.config.ts | 4 ++-- apps/portal/buildspec.yml | 2 +- apps/portal/next.config.ts | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/app/buildspec.yml b/apps/app/buildspec.yml index b6afee6a4..2ab0a25ba 100644 --- a/apps/app/buildspec.yml +++ b/apps/app/buildspec.yml @@ -64,7 +64,7 @@ phases: - | if [ -d "public" ]; then echo "📦 Uploading public/ files to S3..." - aws s3 sync public/ s3://$STATIC_ASSETS_BUCKET/ \ + aws s3 sync public/ s3://$STATIC_ASSETS_BUCKET/app/ \ --cache-control "public, max-age=86400" \ --exclude "*.map" \ --exclude "_next/*" diff --git a/apps/app/next.config.ts b/apps/app/next.config.ts index 57fae7015..2476cac70 100644 --- a/apps/app/next.config.ts +++ b/apps/app/next.config.ts @@ -3,8 +3,8 @@ import path from 'path'; import './src/env.mjs'; const config: NextConfig = { - // Use S3 bucket for static assets - assetPrefix: process.env.NODE_ENV === 'production' ? process.env.STATIC_ASSETS_URL : '', + // Use S3 bucket for static assets with app-specific path + assetPrefix: process.env.NODE_ENV === 'production' ? `${process.env.STATIC_ASSETS_URL}/app` : '', poweredByHeader: false, reactStrictMode: true, transpilePackages: ['@trycompai/db'], diff --git a/apps/portal/buildspec.yml b/apps/portal/buildspec.yml index 63c47dc8a..0436e4377 100644 --- a/apps/portal/buildspec.yml +++ b/apps/portal/buildspec.yml @@ -62,7 +62,7 @@ phases: - | if [ -d "public" ]; then echo "📦 Uploading public/ files to S3..." - aws s3 sync public/ s3://$STATIC_ASSETS_BUCKET/ \ + aws s3 sync public/ s3://$STATIC_ASSETS_BUCKET/portal/ \ --cache-control "public, max-age=86400" \ --exclude "*.map" \ --exclude "_next/*" diff --git a/apps/portal/next.config.ts b/apps/portal/next.config.ts index cc5d394c1..708d20123 100644 --- a/apps/portal/next.config.ts +++ b/apps/portal/next.config.ts @@ -3,8 +3,9 @@ import path from 'path'; import './src/env.mjs'; const config: NextConfig = { - // Use S3 bucket for static assets - assetPrefix: process.env.NODE_ENV === 'production' ? process.env.STATIC_ASSETS_URL : '', + // Use S3 bucket for static assets with portal-specific path + assetPrefix: + process.env.NODE_ENV === 'production' ? `${process.env.STATIC_ASSETS_URL}/portal` : '', transpilePackages: ['@trycompai/db'], outputFileTracingRoot: path.join(__dirname, '../../'), outputFileTracingIncludes: { From 20027d0fff0e5aaba99908b2660e2258875ab319 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Mon, 4 Aug 2025 17:39:08 -0400 Subject: [PATCH 2/4] chore: add favicon and manifest links to layout for app and portal - Included favicon links and a web app manifest in the layout.tsx files for both app and portal, enhancing the user experience and branding consistency across platforms. --- apps/app/src/app/layout.tsx | 4 ++++ apps/portal/src/app/layout.tsx | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/apps/app/src/app/layout.tsx b/apps/app/src/app/layout.tsx index 78e2a3225..4c064adb2 100644 --- a/apps/app/src/app/layout.tsx +++ b/apps/app/src/app/layout.tsx @@ -86,6 +86,10 @@ export default async function Layout({ children }: { children: React.ReactNode } return ( + + + + {dubIsEnabled && dubReferUrl && ( + + + + + + Date: Mon, 4 Aug 2025 17:54:09 -0400 Subject: [PATCH 3/4] chore: add redirects for static assets in next.config for app and portal - Implemented redirects in next.config.ts files for both app and portal to serve static assets from a specified STATIC_ASSETS_URL in production, improving asset management and organization. --- apps/app/next.config.ts | 27 +++++++++++++++++++++++++++ apps/portal/next.config.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/apps/app/next.config.ts b/apps/app/next.config.ts index 2476cac70..6923bb672 100644 --- a/apps/app/next.config.ts +++ b/apps/app/next.config.ts @@ -84,6 +84,33 @@ const config: NextConfig = { }, ]; }, + async redirects() { + if (process.env.NODE_ENV === 'production' && process.env.STATIC_ASSETS_URL) { + return [ + { + source: '/favicon.ico', + destination: `${process.env.STATIC_ASSETS_URL}/app/favicon.ico`, + permanent: true, + }, + { + source: '/favicon-96x96.png', + destination: `${process.env.STATIC_ASSETS_URL}/app/favicon-96x96.png`, + permanent: true, + }, + { + source: '/apple-touch-icon.png', + destination: `${process.env.STATIC_ASSETS_URL}/app/apple-touch-icon.png`, + permanent: true, + }, + { + source: '/site.webmanifest', + destination: `${process.env.STATIC_ASSETS_URL}/app/site.webmanifest`, + permanent: true, + }, + ]; + } + return []; + }, async rewrites() { return [ { diff --git a/apps/portal/next.config.ts b/apps/portal/next.config.ts index 708d20123..124f81de0 100644 --- a/apps/portal/next.config.ts +++ b/apps/portal/next.config.ts @@ -19,6 +19,33 @@ const config: NextConfig = { }, ], }, + async redirects() { + if (process.env.NODE_ENV === 'production' && process.env.STATIC_ASSETS_URL) { + return [ + { + source: '/favicon.ico', + destination: `${process.env.STATIC_ASSETS_URL}/portal/favicon.ico`, + permanent: true, + }, + { + source: '/favicon-96x96.png', + destination: `${process.env.STATIC_ASSETS_URL}/portal/favicon-96x96.png`, + permanent: true, + }, + { + source: '/apple-touch-icon.png', + destination: `${process.env.STATIC_ASSETS_URL}/portal/apple-touch-icon.png`, + permanent: true, + }, + { + source: '/site.webmanifest', + destination: `${process.env.STATIC_ASSETS_URL}/portal/site.webmanifest`, + permanent: true, + }, + ]; + } + return []; + }, async rewrites() { return [ { From 69dbd4f02ea79b339377b2440403fd71b0e4e273 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Mon, 4 Aug 2025 18:03:48 -0400 Subject: [PATCH 4/4] Fix buildspec.yml: Upload Next.js chunks to app-specific paths - App: .next/static/ -> s3://bucket/app/_next/static/ - Portal: .next/static/ -> s3://bucket/portal/_next/static/ - This prevents asset conflicts between apps --- apps/app/buildspec.yml | 2 +- apps/portal/buildspec.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/app/buildspec.yml b/apps/app/buildspec.yml index 2ab0a25ba..e7da25944 100644 --- a/apps/app/buildspec.yml +++ b/apps/app/buildspec.yml @@ -52,7 +52,7 @@ phases: - | if [ -d ".next/static" ]; then echo "📦 Uploading .next/static/ files to CDN..." - aws s3 sync .next/static/ s3://$STATIC_ASSETS_BUCKET/_next/static/ \ + aws s3 sync .next/static/ s3://$STATIC_ASSETS_BUCKET/app/_next/static/ \ --cache-control "public, max-age=31536000, immutable" \ --exclude "*.map" echo "✅ Uploaded Next.js static assets to S3" diff --git a/apps/portal/buildspec.yml b/apps/portal/buildspec.yml index 0436e4377..458eeaec8 100644 --- a/apps/portal/buildspec.yml +++ b/apps/portal/buildspec.yml @@ -50,7 +50,7 @@ phases: - | if [ -d ".next/static" ]; then echo "📦 Uploading .next/static/ files to CDN..." - aws s3 sync .next/static/ s3://$STATIC_ASSETS_BUCKET/_next/static/ \ + aws s3 sync .next/static/ s3://$STATIC_ASSETS_BUCKET/portal/_next/static/ \ --cache-control "public, max-age=31536000, immutable" \ --exclude "*.map" echo "✅ Uploaded Next.js static assets to S3"