-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fixed the cors error in contibutor section #112
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@ayushhunt is attempting to deploy a commit to the BlueFinZ Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe pull request modifies the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AboutComponent
participant API
User->>AboutComponent: Request About Page
AboutComponent->>API: Fetch Contributors
API-->>AboutComponent: Return Contributor Data
AboutComponent-->>User: Display Contributors
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
apps/www/app/(routes)/about/page.tsx (2)
Line range hint
28-36
: Consider enhancing error handling and loading state.The current implementation could benefit from proper error handling and loading state management:
- Missing loading state indicator during fetch
- No user-friendly error message display
- Basic error logging might miss important details
Consider implementing this improved version:
export default function About() { const [contributors, setContributors] = useState<ContributorData[]>([]); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState<string | null>(null); useEffect(() => { const fetchContributors = async () => { + setIsLoading(true); + setError(null); try { const response = await fetch(fetchUrl); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } const data = await response.json(); - console.log(data); setContributors(data.contributorsData); } catch (e) { - console.log(e); + console.error('Failed to fetch contributors:', e); + setError('Failed to load contributors. Please try again later.'); + } finally { + setIsLoading(false); } }; fetchContributors(); }, []);
Line range hint
28-31
: Consider adding CORS-specific configurations.While changing the API domain helps, adding proper CORS configurations would make the implementation more robust.
Consider adding these configurations to the fetch call:
- const response = await fetch(fetchUrl); + const response = await fetch(fetchUrl, { + credentials: 'same-origin', + headers: { + 'Accept': 'application/json' + } + });
@@ -21,7 +21,7 @@ export default function About() { | |||
const [contributors, setContributors] = useState<ContributorData[]>([]); | |||
const fetchUrl = | |||
process.env.NODE_ENV === "production" | |||
? "https://app.plura.pro/v1/contributors" | |||
? "https://api.plura.pro/v1/contributors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Update required: Found additional instances of app.plura.pro
that need to be changed
The old domain app.plura.pro
is still being used in several files:
packages/auth/src/auth.ts
: Used in authentication configurationapps/triggers/src/site.status.ts
: Used in events endpointapps/api/middleware.ts
: Used in middleware configurationapps/api/app/v1/[[...route]]/route.ts
: Used in API route configuration
These instances should also be updated to api.plura.pro
for consistency and to fully resolve CORS issues across the application.
🔗 Analysis chain
LGTM! The API endpoint change should resolve the CORS issue.
The change from app.plura.pro
to api.plura.pro
follows the best practice of separating API services to a dedicated subdomain.
Let's verify if there are any other instances of the old domain that might need updating:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other instances of the old domain
rg "app.plura.pro" --type-add 'frontend:*.{tsx,ts,js,jsx}'
Length of output: 308
Choose a template by going to
Preview
tab and selecting appropriate optionSummary by CodeRabbit