Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions calc-backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import express from "express";
import cors from "cors";
import routes from "./server.routes";
import errorMiddleware from "./middlewares/errorHandler.middleware";
import { toNodeHandler } from "better-auth/node";
import { toNodeHandler, fromNodeHeaders} from "better-auth/node";
import { auth } from "./lib/auth";

const PORT = process.env.PORT || 3000;
Expand All @@ -18,7 +18,16 @@ app.use(cors({

app.all("/api/auth/*", toNodeHandler(auth));

app.use(express.json())
/*
app.get("/api/session", async (req, res) => {
const session = await auth.api.getSession({
headers: fromNodeHeaders(req.headers),
});
return res.json(session);
});
*/

app.use(express.json()) // use this after better auth

// Prefixes the endpoint with /
app.use('/',routes);
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions calc-frontend/src/App/RootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import CalcLogo from "../components/CalcLogo"
import { authClient } from "../lib/auth-client";
import { Avatar, AvatarFallback, AvatarImage } from "../components/ui/avatar"

await authClient.getSession(); // get session

function RootLayout() {
const session = authClient.useSession();

Expand Down