mirror of
https://github.com/Radiquum/AniX.git
synced 2025-05-03 03:19:41 +05:00
feat: add authorization!
This commit is contained in:
parent
f3667eb209
commit
3a800a4933
7 changed files with 248 additions and 1 deletions
21
app/api/profile/[id]/route.js
Normal file
21
app/api/profile/[id]/route.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { fetchDataViaGet } from "@/app/api/utils";
|
||||
import { ENDPOINTS } from "@/app/api/config";
|
||||
|
||||
export async function GET(request, params) {
|
||||
const token = request.nextUrl.searchParams.get(["token"]) || null;
|
||||
let url = new URL(`${ENDPOINTS.profile}/${params["params"]["id"]}`);
|
||||
if (token) {
|
||||
url.searchParams.set("token", token);
|
||||
}
|
||||
|
||||
const response = await fetchDataViaGet(url.toString());
|
||||
if (!response) {
|
||||
return NextResponse.json({ message: "Server Error" }, { status: 500 });
|
||||
}
|
||||
if (!response.profile) {
|
||||
return NextResponse.json({ message: "Profile not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
return NextResponse.json(response);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue