-
Notifications
You must be signed in to change notification settings - Fork 121
Fix session cookies with proper CORS and credentialed auth requests #254
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
base: main
Are you sure you want to change the base?
Changes from all 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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,37 @@ const SignUp: React.FC = () => { | |||||||||||||
| setIsLoading(true); | ||||||||||||||
|
|
||||||||||||||
| try { | ||||||||||||||
| const response = await axios.post( | ||||||||||||||
| `${backendUrl}/api/auth/signup`, | ||||||||||||||
| formData, | ||||||||||||||
| { withCredentials: true } | ||||||||||||||
| ); | ||||||||||||||
| setMessage(response.data.message); // Show success message from backend | ||||||||||||||
|
|
||||||||||||||
| // Navigate to login page after successful signup | ||||||||||||||
| if (response.data.message === 'User created successfully') { | ||||||||||||||
| navigate("/login");} | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| // // Simulate API call (replace with your actual backend integration) | ||||||||||||||
| // try { | ||||||||||||||
| // // Mock successful signup | ||||||||||||||
| // setMessage("Account created successfully! Redirecting to login..."); | ||||||||||||||
|
|
||||||||||||||
| // // In your actual implementation, integrate with your backend here: | ||||||||||||||
| // // const response = await fetch(`${backendUrl}/api/auth/signup`, { | ||||||||||||||
| // // method: 'POST', | ||||||||||||||
| // // headers: { 'Content-Type': 'application/json' }, | ||||||||||||||
| // // body: JSON.stringify(formData) | ||||||||||||||
| // // }); | ||||||||||||||
|
|
||||||||||||||
| // setTimeout(() => { | ||||||||||||||
| // // Navigate to login page in your actual implementation | ||||||||||||||
| // console.log("Redirecting to login page..."); | ||||||||||||||
| // }, 2000); | ||||||||||||||
|
|
||||||||||||||
| } catch (error) { | ||||||||||||||
| setMessage("Something went wrong. Please try again."); | ||||||||||||||
|
Comment on lines
+70
to
+71
Contributor
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. Restore backend error message extraction for better UX. The new error handler uses a generic message, but the backend likely returns specific validation errors (e.g., "Username already exists", "Invalid email format"). Showing these details helps users understand and fix their input. The previous implementation correctly extracted 🔧 Proposed fix } catch (error) {
- setMessage("Something went wrong. Please try again.");
+ setMessage(
+ (error as any).response?.data?.message || "Something went wrong. Please try again."
+ );📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| const response = await axios.post(`${backendUrl}/api/auth/signup`, formData); | ||||||||||||||
| setMessage(response.data.message); | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
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.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Remove commented-out mock code.
The commented mock API implementation should be deleted entirely. Leaving dead code as comments clutters the codebase and provides no value since the actual implementation is now in place.
🧹 Proposed cleanup
📝 Committable suggestion
🤖 Prompt for AI Agents