[Bug]: Hardcoded IP causing Testing to fail #2

Closed
opened 2026-01-28 09:16:31 -07:00 by jramos · 1 comment
Owner

Description

When deploying to multiple environments to test, the backend database does not respond properly within the app. The IP address is hard coded and needs to be updated to accept .env variables

Steps to Reproduce

Depploy to new environment
Run ./start-servers.sh
Refresh page

"Failed to fetch CVE's" and other API call failures:

{3B226C45-9C01-4E29-9D73-016C17BCA95D}.png

Environment

Microsoft Edge/ Windows 11

Relevant Log Output

No response

### Description When deploying to multiple environments to test, the backend database does not respond properly within the app. The IP address is hard coded and needs to be updated to accept .env variables ### Steps to Reproduce Depploy to new environment Run ./start-servers.sh Refresh page "Failed to fetch CVE's" and other API call failures: <img width="1086" alt="{3B226C45-9C01-4E29-9D73-016C17BCA95D}.png" src="attachments/51c96812-2b02-4924-b831-70d82616586e"> ### Environment Microsoft Edge/ Windows 11 ### Relevant Log Output _No response_
Author
Owner

Files to Create

backend/.env
PORT=3001
CORS_ORIGINS=http://YOUR_IP:3000

frontend/.env
REACT_APP_API_BASE=http://YOUR_IP:3001/api
REACT_APP_API_HOST=http://YOUR_IP:3001

Code Changes

backend/server.js - add at top:
require('dotenv').config();

Replace hardcoded PORT and CORS with process.env values.

frontend/src/App.js - replace hardcoded API_BASE:
const API_BASE = process.env.REACT_APP_API_BASE || 'http://localhost:3001/api';

Critical: Restart Required

React caches env vars at startup. After changes:
pkill -f "react-scripts" && pkill -f node
./start-servers.sh

Page refresh alone will NOT work.

Files to Create backend/.env PORT=3001 CORS_ORIGINS=http://YOUR_IP:3000 frontend/.env REACT_APP_API_BASE=http://YOUR_IP:3001/api REACT_APP_API_HOST=http://YOUR_IP:3001 Code Changes backend/server.js - add at top: require('dotenv').config(); Replace hardcoded PORT and CORS with process.env values. frontend/src/App.js - replace hardcoded API_BASE: const API_BASE = process.env.REACT_APP_API_BASE || 'http://localhost:3001/api'; Critical: Restart Required React caches env vars at startup. After changes: pkill -f "react-scripts" && pkill -f node ./start-servers.sh Page refresh alone will NOT work.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jramos/cve-dashboard#2