Chi Hao
Explore posts from serversunable to retrieve cookie value
hi that was very long time ago🤣, my solution was this.
If you are using a front end framework like Astro, NextJS, Nuxt and etc, just set the cookie via the server side (API endpoints, server actions) instead of using hono to set the cookie. If you really want your hono backend to set cookie in your front end which is on another domain, just make sure to configure both to be on the same domain like localhost (but I did'nt managed to do this). Since I'm using Astro, the flow was like this
Astro client side (call
/api/csrf
) --> astro server side (/api/csrf
sets csrf cookie and return csrf token value) --> astro client side (call /api/backend
with csrf token in header) --> astro server side (/api/backend
checks whether csrf token header and cookie value is same then proceed to call hono in server side). So, actually the server side or api endpoint will be acting like a proxy server.41 replies
unable to retrieve cookie value
for some reason this doesnt work, even though i can go to localhost:8787 on my browser, but i cant fetch from it.
so i've decided to run my frontend on http://127.0.0.1:4321/testcsrf and my backend on http://127.0.0.1:8787
the route to set cookie is at http://127.0.0.1:8787/csrf, so i call this url in my frontend and I wonder why it doesnt set the cookie at http://127.0.0.1:4321.
if I go to this url in my browser http://127.0.0.1:8787/csrf, it does set the cookie and at it shows domain 127.0.0.1.
this is how I'm fetching in my frontend but the cookie is not set
41 replies
unable to retrieve cookie value
i think im facing this issue https://stackoverflow.com/questions/12491750/localhost-doesnt-point-to-127-0-0-1#:~:text=Do%20the%20following%3A%20Go%20to%20-%3Ewindows-%3Esystem32-%3Eetc-%3Ehost,remove-%3E%20%3A%3A1%20localhost%20set-%3E%20127.0.0.1%20localhost
41 replies
unable to retrieve cookie value
in my frontend, i can call http://127.0.0.1:8787 but why I cant call http://localhost:8787 ?
however i can go to my browser at http://localhost:8787, and it will show me the response text. Does this mean i need to reconfigure my windows system to map localhost to 127.0.0.1 ?
41 replies
unable to retrieve cookie value
since my astro is being deployed to cloudflare pages (mypage.com) and hono deployed to cloudflare worker (maybe i can set it to backend.mypage.com)
however in local development, i dont think I can do something like subdomain?
41 replies
unable to retrieve cookie value
I may not understand your suggestion clearly. my astro is at http://localhost:4321 and my backend is at http://127.0.0.1:8787.
Do I call my api in my astro server side and use the astro server side to set the cookie value which I receive from my backend response?
41 replies
unable to retrieve cookie value
however it's not setting the cookie at http://localhost:4321/, so i wonder if it cannot set cookie at different domain
41 replies
unable to retrieve cookie value
however the cookie is still not in the list of cookies at http://localhost4321
41 replies
DTDrizzle Team
•Created by Chi Hao on 4/11/2024 in #help
update multiple rows is not working. PostgresError: column excluded.name does not exist
Thanks for the help!
6 replies