From 5ce716d2ab9167231fb5bf47dfa2e5ff4c56bb2c Mon Sep 17 00:00:00 2001 From: NotII <46204250+NotII@users.noreply.github.com> Date: Mon, 1 Sep 2025 16:48:42 +0100 Subject: [PATCH] Refactor docs structure and update API env config Moved documentation files into a new docs/ directory and added a documentation index (docs/README.md). Updated the main README with improved project and documentation details. Set explicit API environment variables in Dockerfile for production. Enhanced next.config.mjs with improved API_BASE_URL handling and logging for better deployment clarity. --- Dockerfile | 6 +-- README.md | 13 ++++- ANALYTICS.md => docs/ANALYTICS.md | 0 .../CAPROVER-DEPLOYMENT-FIX.md | 0 OPTIMIZED-BUILD.md => docs/OPTIMIZED-BUILD.md | 0 docs/README.md | 51 +++++++++++++++++++ lib/README.md => docs/lib-readme.md | 0 next.config.mjs | 6 ++- 8 files changed, 70 insertions(+), 6 deletions(-) rename ANALYTICS.md => docs/ANALYTICS.md (100%) rename CAPROVER-DEPLOYMENT-FIX.md => docs/CAPROVER-DEPLOYMENT-FIX.md (100%) rename OPTIMIZED-BUILD.md => docs/OPTIMIZED-BUILD.md (100%) create mode 100644 docs/README.md rename lib/README.md => docs/lib-readme.md (100%) diff --git a/Dockerfile b/Dockerfile index 895cf27..d977a11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,9 +40,9 @@ EXPOSE 3000 ENV NODE_ENV=production ENV NEXT_PUBLIC_API_URL=/api # Backend API URL should be set via deployment environment -# ENV SERVER_API_URL=set_via_deployment -# ENV API_BASE_URL=set_via_deployment -# ENV API_HOSTNAME=set_via_deployment +ENV SERVER_API_URL=https://internal-api.inboxi.ng/api +ENV API_BASE_URL=https://internal-api.inboxi.ng +ENV API_HOSTNAME=internal-api.inboxi.ng # Set GIT_COMMIT_SHA environment variable in the final image by reading the file ENV GIT_COMMIT_SHA="$(cat /app/git_commit_sha)" diff --git a/README.md b/README.md index e215bc4..52a3600 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,15 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). +# 🔥 Ember Market Frontend + +A modern Next.js frontend for the Ember Market platform, built with TypeScript, Tailwind CSS, and Shadcn UI components. + +## 📚 Documentation + +For detailed documentation, guides, and troubleshooting, see the **[docs/](./docs/)** folder: + +- **[📋 Documentation Index](./docs/README.md)** - Complete documentation overview +- **[🚀 CapRover Deployment](./docs/CAPROVER-DEPLOYMENT-FIX.md)** - Deployment fixes and environment setup +- **[📊 Analytics](./docs/ANALYTICS.md)** - Analytics implementation and insights +- **[⚡ Build Optimization](./docs/OPTIMIZED-BUILD.md)** - Performance and build optimizations ## Getting Started diff --git a/ANALYTICS.md b/docs/ANALYTICS.md similarity index 100% rename from ANALYTICS.md rename to docs/ANALYTICS.md diff --git a/CAPROVER-DEPLOYMENT-FIX.md b/docs/CAPROVER-DEPLOYMENT-FIX.md similarity index 100% rename from CAPROVER-DEPLOYMENT-FIX.md rename to docs/CAPROVER-DEPLOYMENT-FIX.md diff --git a/OPTIMIZED-BUILD.md b/docs/OPTIMIZED-BUILD.md similarity index 100% rename from OPTIMIZED-BUILD.md rename to docs/OPTIMIZED-BUILD.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..7c89b95 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,51 @@ +# 📚 Ember Market Frontend Documentation + +Welcome to the Ember Market Frontend documentation. This folder contains all technical documentation, guides, and references for the project. + +## 📋 Documentation Index + +### 🚀 Deployment & Infrastructure +- **[CapRover Deployment Fix](./CAPROVER-DEPLOYMENT-FIX.md)** - Fixes for 500 errors and environment variable configuration +- **[Optimized Build](./OPTIMIZED-BUILD.md)** - Build optimization strategies and performance improvements + +### 📊 Features & Analytics +- **[Analytics](./ANALYTICS.md)** - Analytics implementation and data insights documentation + +### 🛠️ Development +- **[Lib Documentation](./lib-readme.md)** - Library utilities and helper functions + +## 🏗️ Project Structure + +``` +docs/ +├── README.md # This index file +├── CAPROVER-DEPLOYMENT-FIX.md # Deployment troubleshooting +├── ANALYTICS.md # Analytics documentation +├── OPTIMIZED-BUILD.md # Build optimization guide +└── lib-readme.md # Library utilities guide +``` + +## 🔗 Related Documentation + +- **[Main README](../README.md)** - Project overview and setup instructions +- **[Backend Documentation](../../ember-market-backend/README.md)** - Backend API documentation +- **[Payments Documentation](../../ember-market-payments/README.md)** - Payment system documentation + +## 📝 Contributing to Documentation + +When adding new documentation: + +1. Create `.md` files in this `docs/` folder +2. Update this README.md index +3. Use clear, descriptive filenames +4. Include relevant emojis for easy scanning +5. Cross-reference related documents + +## 🏷️ Document Categories + +- **🚀 Deployment** - CapRover, Docker, environment setup +- **📊 Analytics** - Data tracking, insights, reporting +- **🛠️ Development** - Code guides, utilities, best practices +- **🔧 Configuration** - Environment variables, API setup +- **🐛 Troubleshooting** - Common issues and fixes + diff --git a/lib/README.md b/docs/lib-readme.md similarity index 100% rename from lib/README.md rename to docs/lib-readme.md diff --git a/next.config.mjs b/next.config.mjs index 1eb211a..629f957 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -24,11 +24,12 @@ const baseConfig = { ], }, async rewrites() { - const apiBaseUrl = process.env.API_BASE_URL || 'http://localhost:3001'; + const apiBaseUrl = process.env.API_BASE_URL; // Ensure API_BASE_URL is valid to prevent 500 errors if (!apiBaseUrl || apiBaseUrl === 'undefined') { - console.warn('API_BASE_URL not set, using localhost fallback'); + console.warn('⚠️ API_BASE_URL not set! Set it to your backend domain'); + console.warn('⚠️ Using localhost fallback - this will fail in production!'); return [ { source: '/api/:path*', @@ -37,6 +38,7 @@ const baseConfig = { ]; } + console.log(`🔗 API rewrites pointing to: ${apiBaseUrl}`); return [ { source: '/api/:path*',