diff --git a/apps/app/buildspec.yml b/apps/app/buildspec.yml index b6afee6a4..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" @@ -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..6923bb672 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'], @@ -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/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 && ( + + + + + +