Back

[SOLVED] JSM Social Media App

  • 0
  • Web
Hurricane105
1 Nov, 2023, 17:38

hey i am trying to follow along with this youtube tutorial. If I sign up a user, the user gets saved on appwrite in the auth and database section but i am not redirect to the logged in page and i dont get an user session cookie token (cookieFallback) in the local storage. The code is absolutely the same from the tutorial.

in the console i got a 401 error.

TL;DR
User is following a YouTube tutorial to create a social media app using JSM. After signing up a user, the user is not redirected to the logged-in page and there is no user session cookie token in the local storage. Console shows a 401 error. Another user suggested disabling one of the lines in the useEffect, specifically `cookieFallback === null ||`. The original user tried the suggestion but it didn't solve the issue. Another user suggested adding a console log before the `navigate("/sign-in")` line in the useEffect. Another user insists that their code is correct and the issue may be that the useEffect is not being triggered.
beppoh
1 Nov, 2023, 17:44

It's the use effect, you have to disable one of the lines. I forget which one

Hurricane105
1 Nov, 2023, 18:13

hey thanks for the answer. i tried everything with the useEffect. i dont get the cookieFallback.

beppoh
1 Nov, 2023, 18:17

Are you missing one line?

beppoh
1 Nov, 2023, 18:17

Hold up

beppoh
1 Nov, 2023, 18:17
TypeScript
 useEffect(() => {
    const cookieFallback = localStorage.getItem("cookieFallback");
    if (
      cookieFallback === "[]" ||
      cookieFallback === null ||
      cookieFallback === undefined
    ) {
      navigate("/sign-in");
    }

    checkAuthUser();
  }, []);
beppoh
1 Nov, 2023, 18:17

I believe the line that was causing me issues was, cookieFallback === null ||

Hurricane105
1 Nov, 2023, 18:22

i tried your code, the error is still the same, nothing changed 😦

beppoh
1 Nov, 2023, 18:25

Can you put a console.log(I'm here) before the navigate("/sign-in")?

beppoh
1 Nov, 2023, 18:25

Keep my code, because it's the correct one

beppoh
1 Nov, 2023, 18:26

I'm not sure if your useEffect is being triggered, because it's not creating a cookie for you

beppoh
1 Nov, 2023, 18:27

Can you delete your auth/user, restart your dev env, and try again

Hurricane105
1 Nov, 2023, 18:27

yeah its not getting triggered. the error occurs in the getAccount function in the appwrite/api file

Hurricane105
1 Nov, 2023, 18:28
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more