backend changes

This commit is contained in:
Chandini 2025-09-17 12:12:09 +05:30
parent f3077d53a7
commit 1c4f9b47ed
5 changed files with 53 additions and 7 deletions

45
config/urls.js Normal file
View File

@ -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)}`;
},
};

View File

@ -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

View File

@ -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

View File

@ -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');

View File

@ -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',