Back

how to configure appwrite and web app to test auth in localhost?

  • 1
  • Web
puntogris
16 Dec, 2023, 16:35

Hello everyone, i'm having trouble understanding how to set the auth enviroment in dev(localhost). My idea is to get that cookie saved and use it to make request to appwrite using SSR setting the cookie manually in the request headers.

1- web sdk -> no cookies get saved, only the local storage fallback. 2-rest api -> the cookie gets set with the domain ".cloud.appwrite.io" but as soon as i refresh the page it gets deleted, i asume is something related to the domain.

So my question is how do i make the cookies get set and persisted in localhost dev?

At the moment i don't have a custom domain to set that up. I did create a web app in the appwrite console with the hostname localhost.

TL;DR
The user is having trouble configuring Appwrite and their web app to test authentication on localhost. They are trying to set the cookies and make requests using SSR. They have tried using the web SDK, but only local storage is being used. They have also tried using the REST API, but the cookie gets deleted upon page refresh. They are wondering how to make the cookies persist on localhost. They do not have a custom domain at the moment. Solution: One suggestion is to modify the hosts file. Another suggestion is to search online for information about hosts files. A demo for Svelte is also mentioned.
puntogris
21 Dec, 2023, 03:46

sorry to bother again, anyone has an example of how to implement it? thanks

Drake
21 Dec, 2023, 03:47

You could try to modify your hosts file since you don't have a domain.

Drake
21 Dec, 2023, 03:48

What framework are you using?

puntogris
21 Dec, 2023, 03:48

newbiew here, what would i need to include in the host file? i'm using sveltekit

Drake
21 Dec, 2023, 03:49

Search online about hosts files

Drake
21 Dec, 2023, 03:49

As for svelte, check out this demo: https://svelte-kit.ssr.almostapps.eu/

puntogris
21 Dec, 2023, 03:50

okey, i for sure need to learn more about it. i tried setting the local host to this domain ".cloud.appwrite.io" but didnt work. that would be the correct one to include?

Drake
21 Dec, 2023, 03:53

You can't have the same domain (localhost) pointed at 2 different things

puntogris
21 Dec, 2023, 03:55

ohh, i will look into it. thanks for the help

puntogris
21 Dec, 2023, 04:02

i will add my two cents, i hope you don't mind. maybe it's me that is the complete newbie but it would be helpful if in the docs would say something about this and maybe provide an example on how to handle it. thanks again for the help and love appwrite!

Drake
21 Dec, 2023, 04:19

Usually, I advise against SSR because it's very complicated.

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