-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Description:
The application's Firebase configuration (API key, Auth Domain, etc.) is currently hardcoded directly into a JavaScript file. This is a significant security risk because anyone who views the source code or inspects the site in a browser can see these credentials. This could lead to unauthorized access to your Firebase services or unexpected costs if the API keys are used by others.
Solution:
Move these sensitive values into environment variables. In a React project, you should create a .env file in the root directory and prefix the variables with REACT_APP_.
Code Implementation:
Step 1: Create a .env file:
REACT_APP_FIREBASE_API_KEY=your_api_key_here
REACT_APP_FIREBASE_AUTH_DOMAIN=your_auth_domain_here
Step 2: Update client/src/utils/Firebase.js
const firebaseConfig = {
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
// ... repeat for other fields
};
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels