Skip to content

Commit

Permalink
fix(signup): handle cookies in Axios requests for successful signup
Browse files Browse the repository at this point in the history
  • Loading branch information
RutikKulkarni committed Jul 1, 2024
1 parent a3cf730 commit 6e21552
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ app.use(cookieParser());
app.use(
cors({
origin: config.CLIENT_URL,
credentials: true
})
);

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/Signup/SignupHelperFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import { Config } from "../../App";
* @param {Function} setUserData - Function to set the user data state.
* @param {Function} navigate - Function to navigate to a different route.
*/

const registerUser = async (userData, setIsLoading, setUserData, navigate) => {
try {
const validationMessage = validateUserData(userData);
if (validationMessage === true) {
setIsLoading(true);
const response = await axios.post(
`${Config.endpoint}auth/register`,
userData
userData,
{ withCredentials: true } // This is the important part for the cookies
);

if (response.status === 201) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utility/envHelper/envHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export const getConfig = () => {
return {
endpoint:
REACT_ENV === "development"
? "http://localhost:8082/api/v1"
? "http://localhost:8082/api/v1/"
: REACT_ENV === "deployment"
? "https://referralnetworkhub.onrender.com/api/v1"
? "https://referralnetworkhub.onrender.com/api/v1/"
: "",
};
};

0 comments on commit 6e21552

Please sign in to comment.