Amodeus R.
Amodeus R.
Explore posts from servers
HHono
Created by Mattèo on 1/31/2025 in #help
Using @hono/auth-js with one API server (auth) and one web server (front) ?
Well, I just needed to solve a somewhat similar problem, trying to make cross-site authentication, though I'm not sure it could be of any help for you, but I'll leave my experience here, who knows it might help you in a way or another. Basically I configured the backend to make authentication with cookies, so I needed to put these options for the cookies options. (I'm using Kinde by the way, so there's that)
const cookiesOptions: CookieOptions = {
httpOnly: true,
secure: true,
sameSite: "None",
} as const;
const cookiesOptions: CookieOptions = {
httpOnly: true,
secure: true,
sameSite: "None",
} as const;
And then I passed it to the setCookie function from hono/cookie with the values I wanted to store and such. in the cors configuration I added credentials: true, and using Honojs client I also configured it to include credentials as following below
const client = hc<ApiRoutes>("http://localhost:3000/", {init: {
credentials: "include"
}});
const client = hc<ApiRoutes>("http://localhost:3000/", {init: {
credentials: "include"
}});
It allowed me to make fetch calls from different domains.
11 replies
HHono
Created by Mattèo on 1/31/2025 in #help
Using @hono/auth-js with one API server (auth) and one web server (front) ?
If I'm getting it, you want to make cross-site api calls? Is that right?
11 replies
HHono
Created by Amodeus R. on 2/1/2025 in #help
How to add credentials to a Hono client?
About the hono docs, it's reasonably organized and simple, but it really lacks in profundity and clarity. As you see, I couldn't find what I needed and I would never, because the only thing I knew is that I needed to add the said option, but I'd never find it even if I searched for it because there is nothing stating anything about credentials in Hono Docs. Sure it might be a lack of knowledge of my part, but I've tinkered with other docs in the past that I knew zero things about the tech I was using, and even then I could do exactly what I wanted. I was just hoping I would get a nice experience like that and not be frustratingly stuck in a problem that I know is simple, but I simply can't overcome it because of pure lack of accessibility of knowledge.
29 replies
HHono
Created by Amodeus R. on 2/1/2025 in #help
How to add credentials to a Hono client?
That was exactly what I needed. The init option is where I can put the credentials: "include" option and it worked now. Thanks for you help and time!
29 replies
HHono
Created by Amodeus R. on 2/1/2025 in #help
How to add credentials to a Hono client?
As I said previously, I'm making authentication via cookies, but the cookies aren't being sent because it's a cross-site connection and to make the cookies be sent the fetch function needs the credentials: include added to it, hence I came here to know how to add it to the hono client function, because I don't want to use the fetch function, but the actual honojs client
29 replies
HHono
Created by Amodeus R. on 2/1/2025 in #help
How to add credentials to a Hono client?
The cors are already allowed, the cors error is different from a 401 unauthorized error that as I said I myself configured to happen if the authentication fails. I already shared the repo, so there's nothing more I'm omitting, the only thing I wanted was a way to add the option I said I wanted, since such option made things work with the javascript fetch function, so it'd likely make hono work as well
29 replies
HHono
Created by Amodeus R. on 2/1/2025 in #help
How to add credentials to a Hono client?
Well.. it was simple with the fetch function
29 replies
HHono
Created by Amodeus R. on 2/1/2025 in #help
How to add credentials to a Hono client?
It's simple. I want to access authenticated routes, but whenever I try to access an authenticated route the authentication doesn't work and it returns 401 unauthorized (the message I configured to when it can't authenticate). I don't quite understand why, but I know it works when it's in the same route/port or something like this, but as soon as I change for different ports or sites it doesn't work. Adding the credentials: include to the fetch function and some other configurations in the backend made it work, but I don't see any credentials: include option in Hono, and that's all I need and want to make these routes work cross-site. You can take a look at the repo if you want to here https://github.com/AmodeusR/expense-tracker
29 replies
HHono
Created by Amodeus R. on 2/1/2025 in #help
How to add credentials to a Hono client?
I need a way to include credentials in the frontend, because I'm actually getting/setting cookies in the backend, but for some reason it sets but doesn't seem to be getting it, or at least it doesn't recognize it somehow, because it always throws an unauthorized route error. My API call only worked when I used a normal fetch with the option credentials included, or when it wasn't a cross-site request, that's why I think the problem is the lack of credentials included
29 replies
HHono
Created by Amodeus R. on 1/8/2025 in #help
Error cannot file module "@hono/bun" (TS2307)
Thanks, that was the problem 🙏
7 replies