Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions productionized/pulse-fetch/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# Get one at: https://www.firecrawl.dev/
FIRECRAWL_API_KEY=your-firecrawl-api-key-here

# Firecrawl API Base URL (optional)
# Custom base URL for Firecrawl API (useful for self-hosted instances)
# Defaults to: https://api.firecrawl.dev
# FIRECRAWL_API_BASE_URL=https://api.firecrawl.dev

# BrightData API Key (optional)
# Get one at: https://brightdata.com/ from the Web Unlocker product
# Just provide the token - 'Bearer ' will be prepended automatically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export async function scrapeWithFirecrawl(
error?: string;
}> {
try {
const response = await fetch('https://api.firecrawl.dev/v1/scrape', {
const baseUrl = process.env.FIRECRAWL_API_BASE_URL || 'https://api.firecrawl.dev';
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base URL should be validated to prevent injection attacks. Consider validating that it starts with 'http://' or 'https://' and doesn't contain path traversal characters. For example: if (baseUrl && !/^https?:\/\/.+$/.test(baseUrl)) { throw new Error('Invalid FIRECRAWL_API_BASE_URL'); }

Suggested change
const baseUrl = process.env.FIRECRAWL_API_BASE_URL || 'https://api.firecrawl.dev';
const baseUrl = process.env.FIRECRAWL_API_BASE_URL || 'https://api.firecrawl.dev';
// Validate baseUrl to prevent injection attacks
if (
baseUrl &&
(!/^https?:\/\/[^\\]+$/.test(baseUrl) || baseUrl.includes('..'))
) {
throw new Error('Invalid FIRECRAWL_API_BASE_URL');
}

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base URL is resolved on every function call. Consider moving this to a module-level constant to avoid repeated environment variable lookups and improve performance.

Copilot uses AI. Check for mistakes.
const response = await fetch(`${baseUrl}/v1/scrape`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down