Skip to content

Commit

Permalink
wip fix auth
Browse files Browse the repository at this point in the history
  • Loading branch information
rin-yato committed Sep 20, 2024
1 parent 4c4c136 commit c5510d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/api/src/setup/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function registerAuthMiddleware(app: App) {
startTime(c, METRIC_NAME);

const sessionId = getCookie(c, SESSION_COOKIE_NAME);
console.log("session cookie", sessionId);

if (!sessionId) {
c.set("user", null);
Expand All @@ -29,6 +30,7 @@ export function registerAuthMiddleware(app: App) {

startTime(c, "validate-session");
const session = await lucia.validateSession(sessionId).then(ok).catch(err);
console.log("session", session);
endTime(c, "validate-session");

if (session.error) {
Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/setup/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { logger } from "./logger";

export function registerGlobalErrorHandler(app: App) {
app.onError((err, c) => {
console.error("error", { err, reqHeader: c.req.header });

if (err instanceof ApiError) {
const { status, message, details, name, stack, cause } = err;

logger.error({
header: c.req.header,
cause,
stack,
status,
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { env } from "./env";

export const api = ky.extend({
prefixUrl: env.VITE_API_URL,
mode: "cors",
credentials: "include",
retry: 0,
hooks: {
Expand Down

0 comments on commit c5510d0

Please sign in to comment.