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
#[SOLVED] Coockies
1 messages · Page 1 of 1 (latest)
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
should i add appwrite endpoint in my appwrite cloud ?
To set up the custom domain, you need to go to project settings and add a domain there. This makes Appwrite API accessible on your custom subdomain
i can't buy my own domain currently , am still student , is there anything else i can do ?
May I ask on what domain does your frontnet currently run? Feel free to replace sensitive parts
localhost 💀
I see. For local development, feel free to ignore the warnings
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
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
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
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.
yes , but maybe the code will not be enough , how about a repo ?
Even better 🔥
i will push to github and send you the link and .env vars
this is the link to that repo https://github.com/SouhailM07/testing-classic-auth
those .env vars
NEXT_PUBLIC_ENDPOINT=https://cloud.appwrite.io/v1
NEXT_PUBLIC_PROJECT_ID=
NEXT_PUBLIC_DB_ID=
NEXT_PUBLIC_USERS_COLLECTION_ID=
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
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>
</>
);
}
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
Looks good to me 🔥
it worked , thanks for your help 🫡