-
Notifications
You must be signed in to change notification settings - Fork 4
Update main.py #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,16 @@ | |
| version="1.0.0" | ||
arvi18 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( 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 | ||
arvi18 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security Improvement: The PR correctly replaces the permissive CORS wildcard origin ( There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = [ | ||
| "http://localhost", | ||
| "http://localhost:3000", # React or frontend dev server | ||
| "https://your-frontend-domain.com" # Add your deployed frontend URL here | ||
| ] | ||
|
|
||
| app.add_middleware( | ||
| CORSMiddleware, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documentation Issue: The comment suggests using |
||
| 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=["*"], | ||
|
|
@@ -51,4 +57,4 @@ async def root(): | |
| "auth": "/auth", | ||
arvi18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "protected": "/protected" | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.