-
Notifications
You must be signed in to change notification settings - Fork 61.1k
Qwen #6538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Qwen #6538
Changes from all commits
861d854
4aaa9db
e3fc9ee
cdeb278
b07760f
ee25e4a
8af4d7a
a043f03
4ec717f
972f957
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!-- comment detail in vietnamese --> | ||
app/store/config.ts | ||
|
||
comment detail in vietnamese |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"use client"; | ||
import { useEffect } from "react"; | ||
import { useSyncStore } from "./store/sync"; | ||
import { showToast } from "./components/ui-lib"; | ||
export default function SyncOnFirstLoad() { | ||
const syncStore = useSyncStore(); | ||
|
||
useEffect(() => { | ||
// Parse cookies using the cookie library | ||
// const cookies = cookie.parse(document.cookie || ""); | ||
// const authToken = cookies["sb-zzgkylsbdgwoohcbompi-auth-token"] || null; | ||
|
||
console.log("[Auth Check] Checking user authentication status"); | ||
|
||
fetch("/api/auth/check") | ||
.then((res) => { | ||
if (res.status === 401) { | ||
console.log("[Auth Check] User is not authenticated"); | ||
// Handle unauthenticated user - redirect or show login modal | ||
|
||
showToast("Please login first"); | ||
|
||
// setTimeout(() => { | ||
// window.location.href = AUTHEN_PAGE; | ||
// }, 500); | ||
|
||
return; | ||
} | ||
|
||
return res.json(); | ||
}) | ||
.then((data) => { | ||
if (data) { | ||
console.log("[Auth Check] User is authenticated:", data.user); | ||
|
||
// Assuming data.user contains the user information(user email) | ||
const email = data.user.email || ""; | ||
|
||
// Only update upstash.username, keep other params | ||
syncStore.update((config) => (config.upstash.username = email)); | ||
|
||
// You can now use the user data as needed | ||
// syncStore.sync(); | ||
// console.log("[Sync] User data synced successfully"); | ||
} | ||
}) | ||
.catch((e) => { | ||
console.error("[Auth Check] Error checking authentication:", e); | ||
// Handle error appropriately | ||
}); | ||
}, []); | ||
|
||
return null; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,22 +1,16 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { getServerSideConfig } from "@/app/config/server"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ALIBABA_BASE_URL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ApiPath, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ModelProvider, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ServiceProvider, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} from "@/app/constant"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { ALIBABA_BASE_URL, ApiPath, ModelProvider } from "@/app/constant"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { prettyObject } from "@/app/utils/format"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { NextRequest, NextResponse } from "next/server"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { auth } from "@/app/api/auth"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { isModelNotavailableInServer } from "@/app/utils/model"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const serverConfig = getServerSideConfig(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export async function handle( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
req: NextRequest, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ params }: { params: { path: string[] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log("[Alibaba Route] params ", params); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.log("[Alibaba Route] params ", params); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (req.method === "OPTIONS") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return NextResponse.json({ body: "OK" }, { status: 200 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -33,7 +27,7 @@ export async function handle( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const response = await request(req); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.error("[Alibaba] ", e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.error("[Alibaba] ", e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return NextResponse.json(prettyObject(e)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -42,7 +36,9 @@ async function request(req: NextRequest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const controller = new AbortController(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// alibaba use base url or just remove the path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.Alibaba, ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let path = `${req.nextUrl.pathname}` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.replaceAll(ApiPath.Alibaba, "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.replace("/api", ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let baseUrl = serverConfig.alibabaUrl || ALIBABA_BASE_URL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -65,11 +61,14 @@ async function request(req: NextRequest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const fetchUrl = `${baseUrl}${path}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.log("[Alibaba] fetchUrl", fetchUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const fetchOptions: RequestInit = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Content-Type": "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Authorization: req.headers.get("Authorization") ?? "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"X-DashScope-SSE": req.headers.get("X-DashScope-SSE") ?? "disable", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"X-DashScope-SSE": req.headers.get("X-DashScope-SSE") ?? "enable", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
method: req.method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
body: req.body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -79,34 +78,85 @@ async function request(req: NextRequest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
signal: controller.signal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.log("[Proxy] Alibaba options: ", fetchOptions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// #1815 try to refuse some request to some models | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (serverConfig.customModels && req.body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const clonedBody = await req.text(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fetchOptions.body = clonedBody; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let jsonBody: any = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jsonBody = JSON.parse(clonedBody); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Move input.messages to messages at the root level if present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (jsonBody.input && Array.isArray(jsonBody.input.messages)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jsonBody.messages = jsonBody.input.messages; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Remove input.messages to avoid duplication | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
delete jsonBody.input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jsonBody.stream = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+87
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix performance issue with delete operator. The Replace the delete operation with object destructuring: - // Move input.messages to messages at the root level if present
- if (jsonBody.input && Array.isArray(jsonBody.input.messages)) {
- jsonBody.messages = jsonBody.input.messages;
-
- // Remove input.messages to avoid duplication
- delete jsonBody.input;
-
- jsonBody.stream = true;
- }
+ // Move input.messages to messages at the root level if present
+ if (jsonBody.input && Array.isArray(jsonBody.input.messages)) {
+ const { input, ...bodyWithoutInput } = jsonBody;
+ jsonBody = {
+ ...bodyWithoutInput,
+ messages: input.messages,
+ stream: true
+ };
+ } π Committable suggestion
Suggested change
π§° Toolsπͺ Biome (1.9.4)[error] 95-95: Avoid the delete operator which can impact performance. Unsafe fix: Use an undefined assignment instead. (lint/performance/noDelete) π€ Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const current_model = jsonBody?.model; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.log("[Alibaba] custom models", current_model); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//kiem tra xem model co phai la qwen-vl hay khong (vision model) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (current_model && current_model.startsWith("qwen-vl")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log("[Alibaba] current model is qwen-vl"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.log("xu ly hinh anh trong message"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Reformat image objects in messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (Array.isArray(jsonBody.messages)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jsonBody.messages = jsonBody.messages.map((msg: any) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (Array.isArray(msg.content)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
msg.content = msg.content.map((item: any) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (item && typeof item === "object" && "image" in item) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "image_url", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
image_url: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url: item.image, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+105
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Refactor vision model processing and use English comments. The vision model processing logic has several maintainability issues:
Consider refactoring like this: - //kiem tra xem model co phai la qwen-vl hay khong (vision model)
- if (current_model && current_model.startsWith("qwen-vl")) {
- console.log("[Alibaba] current model is qwen-vl");
- console.log("xu ly hinh anh trong message");
-
- // Reformat image objects in messages
- if (Array.isArray(jsonBody.messages)) {
- jsonBody.messages = jsonBody.messages.map((msg: any) => {
- if (Array.isArray(msg.content)) {
- msg.content = msg.content.map((item: any) => {
- if (item && typeof item === "object" && "image" in item) {
- return {
- type: "image_url",
- image_url: {
- url: item.image,
- },
- };
- }
- return item;
- });
- }
- return msg;
- });
- }
- }
+ // Check if model is a qwen-vl vision model
+ if (current_model?.startsWith("qwen-vl")) {
+ console.log("[Alibaba] Processing vision model:", current_model);
+ jsonBody.messages = transformVisionMessages(jsonBody.messages);
+ } Add this helper function: function transformVisionMessages(messages: any[]): any[] {
if (!Array.isArray(messages)) return messages;
return messages.map((msg) => {
if (!Array.isArray(msg.content)) return msg;
return {
...msg,
content: msg.content.map((item) => {
if (item && typeof item === "object" && "image" in item) {
return {
type: "image_url",
image_url: { url: item.image },
};
}
return item;
}),
};
});
} π§° Toolsπͺ Biome (1.9.4)[error] 106-106: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) π€ Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.log("[Alibaba] request body json", jsonBody); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fetchOptions.body = JSON.stringify(jsonBody); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fetchOptions.body = clonedBody; // fallback if not JSON | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const jsonBody = JSON.parse(clonedBody) as { model?: string }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.log("[Alibaba] request body", fetchOptions.body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// not undefined and is false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isModelNotavailableInServer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
serverConfig.customModels, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
jsonBody?.model as string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ServiceProvider.Alibaba as string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return NextResponse.json( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
error: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
message: `you are not allowed to use ${jsonBody?.model} model`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
status: 403, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// isModelNotavailableInServer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// serverConfig.customModels, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// jsonBody?.model as string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// ServiceProvider.Alibaba as string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// return NextResponse.json( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// error: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// message: `you are not allowed to use ${jsonBody?.model} model`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// status: 403, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+141
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Remove commented model availability check code. This large block of commented code should either be removed entirely if no longer needed, or uncommented and fixed if the functionality is still required. If this functionality is no longer needed, remove the commented code: - // not undefined and is false
- // if (
- // isModelNotavailableInServer(
- // serverConfig.customModels,
- // jsonBody?.model as string,
- // ServiceProvider.Alibaba as string,
- // )
- // ) {
- // return NextResponse.json(
- // {
- // error: true,
- // message: `you are not allowed to use ${jsonBody?.model} model`,
- // },
- // {
- // status: 403,
- // },
- // );
- // } If this functionality should be retained, please uncomment and ensure the imports are available.
π€ Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
console.error(`[Alibaba] filter`, e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// console.error(`[Alibaba] filter`, e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// /app/api/auth/check/route.ts | ||
import { NextRequest } from "next/server"; | ||
import { checkAuth } from "../../supabase"; | ||
|
||
export async function GET(req: NextRequest) { | ||
const user = await checkAuth(req); | ||
|
||
console.log("[Auth] user ", user); | ||
|
||
if (!user) { | ||
return new Response(JSON.stringify({ authenticated: false }), { | ||
status: 401, | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
} | ||
|
||
return new Response(JSON.stringify({ authenticated: true, user }), { | ||
status: 200, | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Remove commented console.log statements instead of leaving them commented out.
Commented-out debug logs should be removed entirely to keep the codebase clean, rather than left as commented code.
Also applies to: 30-30, 65-65, 81-81, 103-103, 131-131, 138-138, 159-159
π€ Prompt for AI Agents