Skip to content

Commit c3d7e2a

Browse files
authored
Merge pull request #421 from Scale3-Labs/ali/adjust-get-project-endpoint
add flexibility for get project endpoint
2 parents 9ee97ef + cb44f9a commit c3d7e2a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

app/api/project/route.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ import { redirect } from "next/navigation";
77
import { NextRequest, NextResponse } from "next/server";
88

99
export async function GET(req: NextRequest) {
10+
// If api key is provided, return the project as it's used by the Python SDK.
11+
const apiKey = req.headers.get("x-api-key");
12+
if (apiKey) {
13+
const response = await authApiKey(apiKey, false);
14+
if (response.status !== 200) {
15+
return response;
16+
}
17+
18+
const data = await response.json();
19+
return NextResponse.json({
20+
project: data.data.project,
21+
});
22+
}
23+
24+
// If no api key is provided, return the project as it's used by the web app.
1025
const session = await getServerSession(authOptions);
1126
if (!session || !session.user) {
1227
redirect("/login");

0 commit comments

Comments
 (0)