Back to all reviewers

Environment variables for configurations

prowler-cloud/prowler
Based on 2 comments
TSX

Store all configurable values such as URLs, API endpoints, and external service locations in environment variables rather than hardcoding them in the codebase. This makes the application more maintainable, secure, and environment-adaptable.

Configurations TSX

Reviewer Prompt

Store all configurable values such as URLs, API endpoints, and external service locations in environment variables rather than hardcoding them in the codebase. This makes the application more maintainable, secure, and environment-adaptable.

Good practice:

// Define the environment variable in your .env file
// NEXT_PUBLIC_RSS_FEED_URL=https://prowler.com/blog/rss

// Then access it directly in your code
const feedUrl = process.env.NEXT_PUBLIC_RSS_FEED_URL;

Avoid:

// Hardcoding configuration values
const RSS_FEED_URL = "https://prowler.com/blog/rss";

For values that combine environment variables with runtime data, access the environment variables directly rather than creating unnecessary intermediate variables:

// Better approach
const cloudFormationUrl = `${process.env.NEXT_PUBLIC_AWS_CLOUDFORMATION_QUICK_LINK}${session?.tenantId}`;

// Rather than
const CLOUDFORMATION_QUICK_LINK = process.env.NEXT_PUBLIC_AWS_CLOUDFORMATION_QUICK_LINK;
const cloudFormationUrl = `${CLOUDFORMATION_QUICK_LINK}${session?.tenantId}`;

This approach improves maintainability, simplifies deployment across different environments, and reduces security risks associated with hardcoded values.

2
Comments Analyzed
TSX
Primary Language
Configurations
Category

Source Discussions