Skip to content

Commit

Permalink
docs: fix hono middleware docs (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-genestier authored Jan 28, 2024
1 parent 34a39c6 commit d7dbdff
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/pages/guides/validate-session-cookies/hono.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import { lucia } from "./auth.js";
import { verifyRequestOrigin } from "lucia";
import { getCookie } from "hono/cookie";

import type { User } from "lucia";
import type { User, Session } from "lucia";

const app = new Hono<{
Variables: {
user: User | null;
session: Session | null;
};
}>();

Expand All @@ -27,9 +28,9 @@ app.use("*", (c, next) => {
if (c.req.method === "GET") {
return next();
}
const originHeader = c.req.headers.get("Origin");
const originHeader = c.req.header("Origin");
// NOTE: You may need to use `X-Forwarded-Host` instead
const hostHeader = c.req.headers.get("Host");
const hostHeader = c.req.header("Host");
if (!originHeader || !hostHeader || !verifyRequestOrigin(originHeader, [hostHeader])) {
return c.body(null, 403);
}
Expand Down

0 comments on commit d7dbdff

Please sign in to comment.