fix(ithc): correct server-side session retrieval for file APIs

This commit is contained in:
2026-11-03 09:25:02 +00:00
parent d417860d1d
commit bb50b17277
6 changed files with 239 additions and 35 deletions
+3 -2
View File
@@ -6,7 +6,8 @@ import { consoleLogger } from "../../../actions/core/logger";
import { hashAPIPath } from "../../../actions/core/hash";
import { respondError, respondSuccess } from "../middleware/apiResponse";
import { fileTypeFromBuffer } from "file-type";
import { getSession } from "next-auth/react";
import { getServerSession } from "next-auth/next";
import { authOptions } from "../auth/[...nextauth]";
import fs from "fs";
import path from "path";
@@ -52,7 +53,7 @@ const forbidden = (res) =>
});
ApiProxy.post(async (req, res) => {
const session = await getSession({ req });
const session = await getServerSession(req, res, authOptions(req, res));
if (
typeof session?.user?.id !== "string" ||
session.user.id.length === 0