Skip to content
Closed
Changes from all 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
10 changes: 7 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
version="1.0.0"
Copy link

Choose a reason for hiding this comment

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

Security Improvement: While replacing the wildcard CORS origin with a specific domain is a good security improvement, hardcoding the frontend URL (https://bubblesort.vercel.com) limits deployment flexibility. Consider using environment variables instead:

origins = os.getenv('ALLOWED_ORIGINS', 'https://bubblesort.vercel.com').split(',')

This would allow for different frontend URLs across environments without code changes.

)

# Add CORS middleware
# CORS setup
Copy link

Choose a reason for hiding this comment

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

Security Improvement: The PR correctly replaces the permissive CORS wildcard origin (["*"]) with a specific origin. However, the URL https://bubblesort.vercel.com appears to be a placeholder based on the comment. Please verify this is the correct production frontend URL before merging.

Copy link

Choose a reason for hiding this comment

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

Configuration Management: Consider moving the CORS origins list to environment variables or a configuration file instead of hardcoding it. This would make it easier to update in different environments without code changes.

origins = [
"https://bubblesort.vercel.com" # Add your deployed frontend URL here
]

app.add_middleware(
CORSMiddleware,
Copy link

Choose a reason for hiding this comment

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

Documentation Issue: The comment suggests using ["*"] for all origins while noting it's not recommended for production. Since this PR is specifically implementing the security best practice of restricting origins, consider removing this comment to avoid confusion for future developers.

allow_origins=["*"], # Configure this properly for production
allow_origins=origins, # You can use ["*"] for all origins (not recommended for production)
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down Expand Up @@ -51,4 +55,4 @@ async def root():
"auth": "/auth",
"protected": "/protected"
}
}
}