aswnss
aswnss
BABetter Auth
Created by aswnss on 5/20/2025 in #help
Infer type is empty in hono
another question in hono , is how should we bind the authtypes ? in the hono website the example given is like this
const router = new Hono<{ Bindings: AuthType }>({
strict: false,
})
const router = new Hono<{ Bindings: AuthType }>({
strict: false,
})
but then i am getting error calling c.get("user")
15 replies
BABetter Auth
Created by aswnss on 5/20/2025 in #help
Infer type is empty in hono
That was the reason.
15 replies
BABetter Auth
Created by aswnss on 5/20/2025 in #help
Infer type is empty in hono
No description
15 replies
BABetter Auth
Created by aswnss on 5/20/2025 in #help
Infer type is empty in hono
No description
15 replies
BABetter Auth
Created by aswnss on 5/20/2025 in #help
Infer type is empty in hono
No description
15 replies
BABetter Auth
Created by aswnss on 5/17/2025 in #help
How do you make fetch call from Nextjs to Hono with auth ?
No description
7 replies
BABetter Auth
Created by aswnss on 5/17/2025 in #help
How do you make fetch call from Nextjs to Hono with auth ?
This is when you have a seperate Nextjs frontend and standalone hono server. I dont think for those you replace or route all the api request from Nextjs through hono will face this issue
7 replies
BABetter Auth
Created by aswnss on 5/17/2025 in #help
How do you make fetch call from Nextjs to Hono with auth ?
When you have an entirely seperate Nextjs frontend and Hono backend , to make an authenticated request
const res = await fetch("http://localhost:5000/api/profile", {
credentials: "include",
headers: header
});
const res = await fetch("http://localhost:5000/api/profile", {
credentials: "include",
headers: header
});
Also you should not use the nextCookies() plugin from auth.ts config file for some reason
7 replies
BABetter Auth
Created by aswnss on 5/17/2025 in #help
Inferring additional fields on hooks
No description
9 replies
BABetter Auth
Created by aswnss on 5/17/2025 in #help
Inferring additional fields on hooks
No description
9 replies
BABetter Auth
Created by aswnss on 5/17/2025 in #help
Inferring additional fields on hooks
It is not being passed as well, getting undefined when console logged
<-- POST /api/auth/sign-up/email
undefined
<-- POST /api/auth/sign-up/email
undefined
9 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
No description
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
this did fix it
{"data":{"session":{"expiresAt":"2025-05-22T14:24:50.913Z","token":"m2DfpinGF4hjbf2Xac9bpDeGdcSYI8h0","createdAt":"2025-05-15T14:24:50.914Z","updatedAt":"2025-05-15T14:24:50.914Z","ipAddress":"","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0","userId":"KTsu89oAeW4PHhQ6aXJ32pjkRVPDfEKx","id":"7PPsj7pDyt5u6v2DrO9hUMdnNVFlSeh9"},"user":{"name":"Aswin Lal M","email":"[email protected]","emailVerified":false,"image":null,"createdAt":"2025-05-15T06:33:04.825Z","updatedAt":"2025-05-15T06:33:04.825Z","id":"KTsu89oAeW4PHhQ6aXJ32pjkRVPDfEKx"}},"error":null}
{"data":{"session":{"expiresAt":"2025-05-22T14:24:50.913Z","token":"m2DfpinGF4hjbf2Xac9bpDeGdcSYI8h0","createdAt":"2025-05-15T14:24:50.914Z","updatedAt":"2025-05-15T14:24:50.914Z","ipAddress":"","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0","userId":"KTsu89oAeW4PHhQ6aXJ32pjkRVPDfEKx","id":"7PPsj7pDyt5u6v2DrO9hUMdnNVFlSeh9"},"user":{"name":"Aswin Lal M","email":"[email protected]","emailVerified":false,"image":null,"createdAt":"2025-05-15T06:33:04.825Z","updatedAt":"2025-05-15T06:33:04.825Z","id":"KTsu89oAeW4PHhQ6aXJ32pjkRVPDfEKx"}},"error":null}
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
did not solve the issue 😥 .. well let me try logging in from a client component now instead of the "use server" method
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
No description
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
cors is set like this in hono
import { Hono } from "hono";
import { etag } from "hono/etag";
import { logger } from "hono/logger";
import { cors } from "hono/cors";
import { prettyJSON } from "hono/pretty-json";

import auth from "@/routes/auth";
import { AuthType } from "@/lib/auth";

const app = new Hono<{ Bindings: AuthType }>({
strict: false,
});

app.use("*", etag(), logger());
app.use(
"*",
cors({
origin: ["http://localhost:3000"],
})
);
app.use("*", prettyJSON());

const routes = [auth] as const;

routes.forEach((route) => {
app.basePath("/api").route("/", route);
});

app.get("/", (c) => {
return c.json(
{
data: {},
message: "Welcome to Hono Backend",
},
200
);
});

app.notFound((c) => {
return c.json({
data: {},
message: "Endpoint not found",
});
});

export default app;
import { Hono } from "hono";
import { etag } from "hono/etag";
import { logger } from "hono/logger";
import { cors } from "hono/cors";
import { prettyJSON } from "hono/pretty-json";

import auth from "@/routes/auth";
import { AuthType } from "@/lib/auth";

const app = new Hono<{ Bindings: AuthType }>({
strict: false,
});

app.use("*", etag(), logger());
app.use(
"*",
cors({
origin: ["http://localhost:3000"],
})
);
app.use("*", prettyJSON());

const routes = [auth] as const;

routes.forEach((route) => {
app.basePath("/api").route("/", route);
});

app.get("/", (c) => {
return c.json(
{
data: {},
message: "Welcome to Hono Backend",
},
200
);
});

app.notFound((c) => {
return c.json({
data: {},
message: "Endpoint not found",
});
});

export default app;
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
No description
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
tried and failed, well i thought of that way too like since i am logging in using server action that happens on the server side and then next cant set the cookies since the auth.ts file is actually on a seperate project ( nextCookies() ) might not be working. So I tried making the login request from a client component but that gave me the issue like you need to have Access-Control-Cross-Credentials set to true , but could not debug that issue ..
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
funny thing is registration and login is actually working .. just cant get the session 😿
36 replies
BABetter Auth
Created by aswnss on 5/15/2025 in #help
Next Hono session is empty
nop new user also returns data null and error null
36 replies