feat: Update environment configurations and deployment scripts for domain flexibility

This commit is contained in:
Salman Qureshi
2025-08-20 20:08:32 +05:30
parent b205369802
commit e0a91b1660
10 changed files with 23 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
# Production Environment Configuration
SERVER_PORT=3000
SERVER_PORT=3001
SERVER_HOST=0.0.0.0
SERVER_PROTOCOL=https
VITE_API_BASE_URL=https://api.yourdomain.com

View File

@@ -1,7 +1,7 @@
# Deployment Guide for CORS Fix
## Problem
CORS error: "Access to fetch at 'https://seedbox-api.isalman.dev/api/auth/login' from origin 'https://seedbox.isalman.dev' has been blocked"
CORS error: "Access to fetch at 'https://seedbox-api.<domain>/api/auth/login' from origin 'https://seedbox.<domain>' has been blocked"
## Solution Steps
@@ -28,7 +28,7 @@ cd /home/toor/seedbox-lite/server-new
NODE_ENV=production \
SERVER_PORT=3001 \
SERVER_HOST=0.0.0.0 \
FRONTEND_URL=https://seedbox.isalman.dev \
FRONTEND_URL=https://seedbox.<domain> \
ACCESS_PASSWORD=seedbox123 \
node index.js
```
@@ -38,7 +38,7 @@ node index.js
**Rebuild with production API URL:**
```bash
cd /home/toor/seedbox-lite/client
VITE_API_BASE_URL=https://seedbox-api.isalman.dev npm run build
VITE_API_BASE_URL=https://seedbox-api.<domain> npm run build
```
**Deploy with PM2:**
@@ -66,8 +66,8 @@ pm2 logs seedbox-backend --lines 20
- Backend runs on port **3001** (as per your .env.production)
- Make sure your reverse proxy/Cloudflare points to port 3001
- CORS is now configured to allow both domains:
- `https://seedbox.isalman.dev` (frontend)
- `https://seedbox-api.isalman.dev` (backend)
- `https://seedbox.<domain>` (frontend)
- `https://seedbox-api.<domain>` (backend)
### 5. Debugging
@@ -77,8 +77,8 @@ If still having issues, check:
pm2 logs seedbox-backend
# Test backend health
curl https://seedbox-api.isalman.dev/api/health
curl https://seedbox-api.<domain>/api/health
# Test CORS manually
curl -H "Origin: https://seedbox.isalman.dev" https://seedbox-api.isalman.dev/api/health
curl -H "Origin: https://seedbox.<domain>" https://seedbox-api.<domain>/api/health
```

View File

@@ -56,7 +56,7 @@ ACCESS_PASSWORD=test123456
#### Frontend (.env.production)
```bash
VITE_API_BASE_URL=https://seedbox-api.isalman.dev
VITE_API_BASE_URL=https://seedbox-api.<domain>
```
### Custom Configuration

View File

@@ -1,5 +1,5 @@
# Production Environment Variables for Docker deployment
VITE_API_BASE_URL=https://seedbox-api.isalman.dev
VITE_API_BASE_URL=https://seedbox-api.<domain>
# App configuration
VITE_APP_NAME=SeedBox Lite

View File

@@ -5,7 +5,7 @@ echo "🔨 Building frontend for production..."
# Set production environment
export NODE_ENV=production
export VITE_API_BASE_URL=https://seedbox-api.isalman.dev
export VITE_API_BASE_URL=https://seedbox-api.<domain>
# Build the project
npm run build

View File

@@ -17,7 +17,7 @@ http {
server {
listen 80;
server_name seedbox.isalman.dev;
server_name seedbox.<domain>;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
@@ -96,7 +96,7 @@ http {
# Additional server block for HTTPS (when SSL certificates are available)
# server {
# listen 443 ssl http2;
# server_name seedbox.isalman.dev;
# server_name seedbox.<domain>;
#
# ssl_certificate /etc/nginx/ssl/seedbox.crt;
# ssl_certificate_key /etc/nginx/ssl/seedbox.key;

View File

@@ -2,7 +2,7 @@
NODE_ENV=production
SERVER_PORT=3001
SERVER_HOST=0.0.0.0
FRONTEND_URL=https://seedbox.isalman.dev
FRONTEND_URL=https://seedbox.<domain>
OMDB_API_KEY=trilogy
ACCESS_PASSWORD=seedbox123

View File

@@ -2,7 +2,7 @@
NODE_ENV=production
SERVER_PORT=3001
SERVER_HOST=0.0.0.0
FRONTEND_URL=https://seedbox.isalman.dev
FRONTEND_URL=https://seedbox.<domain>
OMDB_API_KEY=trilogy
ACCESS_PASSWORD=seedbox123

View File

@@ -1,7 +1,7 @@
SERVER_PORT=3001
SERVER_HOST=0.0.0.0
FRONTEND_URL=https://seedbox.isalman.dev
VITE_API_BASE_URL=https://seedbox-api.isalman.dev
FRONTEND_URL=https://seedbox.<domain>
VITE_API_BASE_URL=https://seedbox-api.<domain>
OMDB_API_KEY=trilogy
ACCESS_PASSWORD=seedbox123
NODE_ENV=production

View File

@@ -6,23 +6,23 @@ echo ""
# Test OPTIONS request (preflight)
echo "1. Testing OPTIONS preflight request:"
curl -X OPTIONS \
-H "Origin: https://seedbox.isalman.dev" \
-H "Origin: https://seedbox.<domain>" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: Content-Type" \
-v \
https://seedbox-api.isalman.dev/api/auth/login
https://seedbox-api.<domain>/api/auth/login
echo ""
echo "2. Testing actual POST request:"
curl -X POST \
-H "Origin: https://seedbox.isalman.dev" \
-H "Origin: https://seedbox.<domain>" \
-H "Content-Type: application/json" \
-d '{"password":"test"}' \
-v \
https://seedbox-api.isalman.dev/api/auth/login
https://seedbox-api.<domain>/api/auth/login
echo ""
echo "3. Testing health endpoint:"
curl -H "Origin: https://seedbox.isalman.dev" \
curl -H "Origin: https://seedbox.<domain>" \
-v \
https://seedbox-api.isalman.dev/api/health
https://seedbox-api.<domain>/api/health