adrianhajdin / social_media_app

Build a modern social app with a stunning UI with a native mobile feel, a special tech stack, an infinite scroll feature, and amazing performance using React JS, Appwrite, TypeScript, and more.
https://jsmastery.pro
1.06k stars 305 forks source link

The app crashed, appwrite error 401 #19

Open athskouroliakos opened 7 months ago

athskouroliakos commented 7 months ago

Everything seemed to be working fine, but now I am getting this error, when I try to perform the basic functionalities like page refresh, logout, save post, even when starting the app. api401

AndrewDonelson commented 7 months ago

I had this as well. In AuthContext.tsx remove the first checkAuthUser() in the useEffect() function. Works for me.


  useEffect(() => {
    console.log("useEffect->cookieFallback");
    const cookieFallback = localStorage.getItem("cookieFallback");
    if (
      cookieFallback === "[]" ||
      cookieFallback === null ||
      cookieFallback === undefined
    ) {
      navigate("/sign-in");
    }

    //checkAuthUser();
  }, []);

  const value = {
    user,
    setUser,
    isLoading,
    isAuthenticated,
    setIsAuthenticated,
    checkAuthUser,
  };

  return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}```
athskouroliakos commented 7 months ago

I had this as well. In AuthContext.tsx remove the first checkAuthUser() in the useEffect() function. Works for me.

  useEffect(() => {
    console.log("useEffect->cookieFallback");
    const cookieFallback = localStorage.getItem("cookieFallback");
    if (
      cookieFallback === "[]" ||
      cookieFallback === null ||
      cookieFallback === undefined
    ) {
      navigate("/sign-in");
    }

    //checkAuthUser();
  }, []);

  const value = {
    user,
    setUser,
    isLoading,
    isAuthenticated,
    setIsAuthenticated,
    checkAuthUser,
  };

  return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}```

Well, I tried that and it stop complaining about AuthContext. But it is still complaining about getCurrentUser on every action (logout, like, save, etc.)

apprwrite_401

EduardDE7 commented 7 months ago

image don't forget permissions in collections settings

Rakshit358 commented 7 months ago

I had this as well. In AuthContext.tsx remove the first checkAuthUser() in the useEffect() function. Works for me.

  useEffect(() => {
    console.log("useEffect->cookieFallback");
    const cookieFallback = localStorage.getItem("cookieFallback");
    if (
      cookieFallback === "[]" ||
      cookieFallback === null ||
      cookieFallback === undefined
    ) {
      navigate("/sign-in");
    }

    //checkAuthUser();
  }, []);

  const value = {
    user,
    setUser,
    isLoading,
    isAuthenticated,
    setIsAuthenticated,
    checkAuthUser,
  };

  return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}```

Well, I tried that and it stop complaining about AuthContext. But it is still complaining about getCurrentUser on every action (logout, like, save, etc.)

apprwrite_401

In the config.ts file try replacing the values of appwriteConfig.projectId and url with the actual projectId and url inside double quotes in the setEnpoint and setProject method.

pratapKadam commented 6 months ago

Failed to load resource: the server responded with a status of 500 () api.ts:52 AppwriteException: Server Error at Client. (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=2b5f3fef:850:17) at Generator.next () at fulfilled (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=2b5f3fef:488:24)

I am getting this error after making the above changes in the code

juliusdhan commented 3 months ago

after doing this trying to signin but the toast message appers, that signin failed , also unable to go to the home page, its automatically redirect to the sigin page