#[SOLVED] Coockies

1 messages · Page 1 of 1 (latest)

surreal void
#

hello everyone , i have a problem with coockies , when i want to get user information using the account.get() promise , i got an infinite amount of errors in my console that saying , Third-party cookie will be blocked. Learn more in the Issues tab, I am using nextjs , and i didn't find a solution for this problem , can someone please help me

gilded sand
# surreal void hello everyone , i have a problem with coockies , when i want to get user inform...

Hi 👋 This warning means a localStorage is used instead of cookies, which is les secure. Not unsecured, but less secure.

Solution to cookie issue is to have Appwrite endpoint be on a subdomain of your frontend. If you app is on myapp.con, then you need Appwrite to point to appwrite.myapp.com, for example. Doing this domain setup follows 1st party cookies policy.

Regarding the spam, thats unusual. Please try to add some console logs to investigate flow of your application. It might be getting stuck in some recursion, causing the spam and tiny DoS attack on your project

surreal void
gilded sand
surreal void
gilded sand
surreal void
#

localhost 💀

gilded sand
#

I see. For local development, feel free to ignore the warnings

surreal void
#

when i use account.get() , i can access the user info , but my console log sends infinite amount of yellow warnings saying
Third-party cookie will be blocked. , this amount of infinite errors can make my pc crash 💀 , it's like using useEffect , without putting an array in it

gilded sand
#

Can you check network tab and see if it's also sending enormous amount of requests to Appwrite Cloud? Running account.get() triggers a HTTP request to /account endpoint

surreal void
#

ok i will check

#

true , it was sending an infinite amount of requests , i closed it before my pc crash

#

and i saw that account word all around to

gilded sand
#

Cool. Then you will need to see where in your Next.js application is the code to get account, and what all scenarios could trigger it.

You can share the code with me and the rest of the community, but we might not have Next.js experience needed for this. Worst-case scenario, you can re-port same question in Next.js Discord community server and see if they have better recommendations to avoid this.

surreal void
#

yes , but maybe the code will not be enough , how about a repo ?

gilded sand
#

Even better 🔥

surreal void
#

i will push to github and send you the link and .env vars

#

those .env vars

#

and when you and your team analyse the code ,please tell me if my ways to login and signIn was good

#

or if there is a better way to do it then mine

gilded sand
#

I think having code directly in in your component will re-run on every re-render I think. I would recommend to put it into useEffect with dependencies of empty array - meaning it will only run once on first component load.

Something liek this:

export default function Home_page() {
  let [user, setUser]: any = useState("");

  useEffect(asycn () => {
    const userDetails = await account.get();
    setUser(userDetails);
  }, []);

  return (
    <>
      <main className="flex justify-center items-center min-h-screen">
        <article className="border-2 border-red-500 min-w-[22rem] h-[10rem] rounded-md">
          <h1 className="text-center text-[1.5rem]">Welcome {user.name}</h1>
          <p>{user.email}</p>
          <p>member since : {user["$createdAt"]}</p>
        </article>
      </main>
    </>
  );
}
surreal void
#

that could work , but what suprised me more , is how did you able to find the file with my problem in very short time ,amazing 🔥

#

btw , please can you tell me if my ways in login and signIn was good or bad

gilded sand
#

Looks good to me 🔥

surreal void
#

it worked , thanks for your help 🫡