diff --git a/config/urls.js b/config/urls.js new file mode 100644 index 0000000..4095df2 --- /dev/null +++ b/config/urls.js @@ -0,0 +1,45 @@ +/** + * BACKEND URL CONFIGURATION - SINGLE SOURCE OF TRUTH + * To switch between environments, simply comment/uncomment the URLs below + */ + +// ======================================== +// LIVE PRODUCTION URLS (Currently Active) +// ======================================== +const FRONTEND_URL = 'https://dashboard.codenuk.com'; +const BACKEND_URL = 'https://backend.codenuk.com'; + +// ======================================== +// LOCAL DEVELOPMENT URLS (Comment out live URLs above and uncomment these) +// ======================================== +// const FRONTEND_URL = 'http://localhost:3001'; +// const BACKEND_URL = 'http://localhost:8000'; + +// ======================================== +// CORS CONFIGURATION (Auto-generated) +// ======================================== +const CORS_CONFIG = { + ORIGIN: FRONTEND_URL, + METHODS: 'GET,POST,PUT,DELETE,PATCH,OPTIONS', + CREDENTIALS: true, +}; + +// ======================================== +// EXPORTS +// ======================================== +module.exports = { + FRONTEND_URL, + BACKEND_URL, + CORS_CONFIG, + + // Helper functions + getApiUrl: (endpoint) => { + const cleanEndpoint = endpoint.startsWith('/') ? endpoint.slice(1) : endpoint; + return `${BACKEND_URL}/${cleanEndpoint}`; + }, + + // Email verification URL helper + getVerificationUrl: (token) => { + return `${FRONTEND_URL}/verify-email?token=${encodeURIComponent(token)}`; + }, +}; diff --git a/docker-compose.yml b/docker-compose.yml index 95e2005..c94ae30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -233,7 +233,7 @@ services: - NODE_ENV=development - PORT=8000 - HOST=0.0.0.0 - - FRONTEND_URL=http://localhost:3001 # Allow all URLs + - FRONTEND_URL=https://dashboard.codenuk.com # Allow all URLs - CORS_ORIGINS=* # Allow all URLs - CORS_METHODS=GET,POST,PUT,DELETE,PATCH,OPTIONS # Add this line - CORS_CREDENTIALS=true # Add this line @@ -507,7 +507,7 @@ services: - JWT_ACCESS_EXPIRY=24h - JWT_ADMIN_ACCESS_EXPIRY=7d - JWT_REFRESH_EXPIRY=7d - - FRONTEND_URL=http://localhost:3001 + - FRONTEND_URL=https://dashboard.codenuk.com # Email Configuration - SMTP_HOST=smtp.gmail.com - SMTP_PORT=587 @@ -613,7 +613,7 @@ services: environment: - PORT=8012 - HOST=0.0.0.0 - - FRONTEND_URL=http://localhost:3001 + - FRONTEND_URL=https://dashboard.codenuk.com - POSTGRES_HOST=postgres - POSTGRES_PORT=5432 - POSTGRES_DB=dev_pipeline diff --git a/services/api-gateway/.env .prod b/services/api-gateway/.env .prod index 0689bbe..e5e5dcd 100644 --- a/services/api-gateway/.env .prod +++ b/services/api-gateway/.env .prod @@ -31,6 +31,6 @@ RABBITMQ_PASSWORD=secure_rabbitmq_password FRONTEND_URL=https://dashboard.codenuk.com # CORS Configuration -CORS_ORIGIN=http://localhost:3001 +CORS_ORIGIN=https://dashboard.codenuk.com CORS_METHODS=GET,POST,PUT,DELETE,PATCH,OPTIONS CORS_CREDENTIALS=true \ No newline at end of file diff --git a/services/user-auth/src/services/authService.js b/services/user-auth/src/services/authService.js index 14a8b19..d233fd6 100644 --- a/services/user-auth/src/services/authService.js +++ b/services/user-auth/src/services/authService.js @@ -149,8 +149,8 @@ class AuthService { async sendVerificationEmail(user) { const token = await this.createEmailVerificationToken(user.id); // Send users to the frontend verification page; the frontend will call the backend and handle redirects - const frontendUrl = process.env.FRONTEND_URL || 'http://localhost:3001'; - const verifyUrl = `${frontendUrl}/verify-email?token=${encodeURIComponent(token)}`; + const { getVerificationUrl } = require('../../../../config/urls'); + const verifyUrl = getVerificationUrl(token); const today = new Date(); const dateString = today.toLocaleDateString('en-US'); diff --git a/services/web-dashboard/src/components/project-builder/BusinessQuestionsScreen.js b/services/web-dashboard/src/components/project-builder/BusinessQuestionsScreen.js index a1e9043..b5e056a 100644 --- a/services/web-dashboard/src/components/project-builder/BusinessQuestionsScreen.js +++ b/services/web-dashboard/src/components/project-builder/BusinessQuestionsScreen.js @@ -28,7 +28,8 @@ export default function BusinessQuestionsScreen() { console.log('🚀 Generating comprehensive business questions for integrated system:', selectedFeatures); // Call the new comprehensive endpoint - const response = await fetch('http://localhost:8000/api/v1/generate-comprehensive-business-questions', { + const { getApiUrl } = require('../../../../../../config/urls'); + const response = await fetch(getApiUrl('api/v1/generate-comprehensive-business-questions'), { method: 'POST', headers: { 'Content-Type': 'application/json',