-
-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setSignedCookie is not setting up the cookie , local host #3421
Comments
I think the screenshot says all of the things: It's not a bug. |
https://medium-blog-worker-serverless.vercel.app/blog/all
Here is my auth middleware :
I am using axios to send request
|
It's difficult to run your code on my machine. Please provide a minimal project that does not use Prisma, Zod, or some libraries. If not, I'll close this issue. |
import { Hono } from 'hono'
import { logger } from "hono/logger"
import { setSignedCookie, setCookie } from "hono/cookie"
const app = new Hono()
app.use(logger())
app.get('/', (c) => {
setSignedCookie(c, "refreshToken", "example_value", "cookie_secret", {
secure: true,
httpOnly: true,
// signingSecret: config.cookieSecret,
// domain: undefined
})
setCookie(c, "accessToken", "example_value", { secure: true, httpOnly: true })
return c.text('Hello Hono!')
})
Deno.serve(app.fetch) refresh token is not set, but accessToken is set here my deno.json {
"nodeModulesDir": "auto",
"imports": {
"hono": "npm:hono@^4.6.4"
},
"tasks": {
"dev": "deno run --watch --allow-net main.ts",
"start": "deno run --allow-net main.ts"
},
"compilerOptions": {
"jsx": "precompile",
"jsxImportSource": "hono/jsx"
},
"deploy": {
"project": "704a9cc1-f4cd-47cd-bfb4-fedd7e72bc2e",
"exclude": [
"**/node_modules"
],
"include": [],
"entrypoint": "main.ts"
}
} |
This issue has been marked as stale due to inactivity. |
Closing this issue due to inactivity. |
What version of Hono are you using?
4.5.11
What runtime/platform is your app running on?
Cloudfare workers
What steps can reproduce the bug?
I try to sign the cookie , it does return token and everything , but when i try to check it in browser , it doesn't show me cookie in application tab via localhost , and says authorization error I am working on a backend using Hono, JWT, and signed cookies. When a user signs in, I generate a JWT token and set it as a signed cookie using the following code:
c```
onst jwt = await sign({ id: user.id }, c.env.JWT_SECRET);
const cookie_secret = c.env.COOKIE_SECRET;
console.log(jwt);
await setSignedCookie(c, "bearer_token", jwt, cookie_secret, {
expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // Cookie expiry (1 week)
httpOnly: true, // Only accessible via HTTP (prevents JavaScript access)
sameSite: "None", // Allows cross-site cookies
});
return c.json({ message: "successfully signed in", success: true });
The text was updated successfully, but these errors were encountered: