Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 7de2315

Browse files
committed
fix: try to fix RequestContentLengthMismatchError: Request body length does not match content-length header
1 parent bb51984 commit 7de2315

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/api/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function isLoggedIn(hashedKey?: string) {
3232
// Client-side
3333
const response = await fetch("/api/chatgpt/verify", {
3434
method: "POST",
35-
body: hashedKey ?? undefined,
35+
body: hashedKey ?? "",
3636
}).then((it) => it.json());
3737

3838
return response.loggedIn;
@@ -47,7 +47,7 @@ export async function isLoggedIn(hashedKey?: string) {
4747
const headersPropagated = { cookie: headers().get("cookie") as string };
4848
const response = await fetch(new URL("/api/chatgpt/verify", new URL(urlStr)), {
4949
method: "POST",
50-
body: hashedKey ?? undefined,
50+
body: hashedKey ?? "",
5151
headers: headersPropagated,
5252
}).then((it) => it.json());
5353
console.log("response", response);

src/pages/api/chatgpt/verify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const handler: NextApiHandler = async (req, res) => {
88
res.status(404).json({ error: "Not found" });
99
return;
1010
}
11-
const keyHashed = req.body ?? req.cookies[SITE_USER_COOKIE] ?? "";
11+
const keyHashed = req.body ? req.body : req.cookies[SITE_USER_COOKIE] ?? "";
1212

1313
if (!keyHashed) {
1414
res.status(200).json({ message: "You're not logged in yet!", loggedIn: false });

0 commit comments

Comments
 (0)