feat: add authorization!

This commit is contained in:
Kentai Radiquum 2024-07-14 03:01:25 +05:00
parent f3667eb209
commit 3a800a4933
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
7 changed files with 248 additions and 1 deletions

View 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);
}