hello new update

This commit is contained in:
2025-07-23 23:34:43 +03:00
parent cb2b4f0d86
commit dfc8e21db1
16 changed files with 279 additions and 277 deletions

View File

@@ -1,52 +0,0 @@
import { type NextRequest, NextResponse } from "next/server"
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const apiUrl = "https://apis.roblox.com/discovery-api/omni-recommendation";
const url = `${apiUrl}?${searchParams.toString()}`;
try {
const response = await fetch(url, {
headers: {
"User-Agent": "OCbwoy3ChanAI/1.0",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Content-Type": "application/json;charset=UTF-8",
"Cookie": request.headers.get("Authorization") || "",
},
});
return NextResponse.json(await response.json());
} catch (error) {
console.error("Error proxying request:", error);
return NextResponse.json({ error: "Internal Server Error" });
}
}
export async function POST(request: NextRequest) {
const { searchParams } = new URL(request.url);
const apiUrl = "https://apis.roblox.com/discovery-api/omni-recommendation";
const url = `${apiUrl}?${searchParams.toString()}`;
try {
const body = await request.json()
const response = await fetch(url, {
method: "POST",
headers: {
"User-Agent": "OCbwoy3ChanAI/1.0",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Content-Type": "application/json;charset=UTF-8",
"Cookie": request.headers.get("Authorization") || "",
},
body: JSON.stringify(body),
});
return NextResponse.json(await response.json());
} catch (error) {
console.error("Error proxying request:", error);
return NextResponse.json({ error: "Internal Server Error" });
}
}

64
app/api/proxy/route.ts Normal file
View File

@@ -0,0 +1,64 @@
async function proxyRequest(request: Request, method: string) {
const { searchParams } = new URL(request.url);
const target = searchParams.get("url");
if (!target) {
return new Response(
JSON.stringify({ error: "Missing `url` query parameter." }),
{
status: 400,
headers: { "Content-Type": "application/json" },
}
);
}
const targetUrl = new URL(target);
const headers = new Headers(request.headers);
headers.delete("host");
headers.delete("accept-encoding"); // ! important
const init: RequestInit = {
method,
headers,
body: method === "GET" || method === "HEAD" ? undefined : request.body,
};
if (init.body !== undefined) {
(init as any).duplex = "half";
}
const response = await fetch(targetUrl, init);
const responseHeaders = new Headers(response.headers);
responseHeaders.delete("content-encoding"); // ! important
return new Response(response.body, {
status: response.status,
headers: responseHeaders,
});
}
export async function GET(request: Request) {
return proxyRequest(request, "GET");
}
export async function HEAD(request: Request) {
return proxyRequest(request, "HEAD");
}
export async function POST(request: Request) {
return proxyRequest(request, "POST");
}
export async function PUT(request: Request) {
return proxyRequest(request, "PUT");
}
export async function DELETE(request: Request) {
return proxyRequest(request, "DELETE");
}
export async function PATCH(request: Request) {
return proxyRequest(request, "PATCH");
}

View File

@@ -1,52 +0,0 @@
import { type NextRequest, NextResponse } from "next/server"
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const apiUrl = "https://thumbnails.roblox.com/v1/batch";
const url = `${apiUrl}?${searchParams.toString()}`;
try {
const response = await fetch(url, {
headers: {
"User-Agent": "OCbwoy3ChanAI/1.0",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Content-Type": "application/json;charset=UTF-8",
"Cookie": request.headers.get("Authorization") || "",
},
});
return NextResponse.json(await response.json());
} catch (error) {
console.error("Error proxying request:", error);
return NextResponse.json({ error: "Internal Server Error" });
}
}
export async function POST(request: NextRequest) {
const { searchParams } = new URL(request.url);
const apiUrl = "https://thumbnails.roblox.com/v1/batch";
const url = `${apiUrl}?${searchParams.toString()}`;
try {
const body = await request.json()
const response = await fetch(url, {
method: "POST",
headers: {
"User-Agent": "OCbwoy3ChanAI/1.0",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Content-Type": "application/json;charset=UTF-8",
"Cookie": request.headers.get("Authorization") || "",
},
body: JSON.stringify(body),
});
return NextResponse.json(await response.json());
} catch (error) {
console.error("Error proxying request:", error);
return NextResponse.json({ error: "Internal Server Error" });
}
}

View File

@@ -1,25 +0,0 @@
import { type NextRequest, NextResponse } from "next/server"
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const apiUrl = "https://users.roblox.com/v1/users/authenticated";
const url = `${apiUrl}?${searchParams.toString()}`;
try {
const response = await fetch(url, {
headers: {
"User-Agent": "OCbwoy3ChanAI/1.0",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Content-Type": "application/json;charset=UTF-8",
"Cookie": request.headers.get("Authorization") || "",
},
});
return NextResponse.json(await response.json());
} catch (error) {
console.error("Error proxying request:", error);
return NextResponse.json({ error: "Internal Server Error" });
}
}

View File

@@ -1,23 +0,0 @@
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
const u = new URL(request.url);
const apiUrl = `https://users.roblox.com/v1/users/${u.searchParams.get("id")}`;
try {
const response = await fetch(apiUrl, {
headers: {
"User-Agent": "OCbwoy3ChanAI/1.0",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Content-Type": "application/json;charset=UTF-8",
"Cookie": request.headers.get("Authorization") || "",
},
});
return NextResponse.json(await response.json());
} catch (error) {
console.error("Error proxying request:", error);
return NextResponse.json({ error: "Internal Server Error" });
}
}

View File

@@ -2,35 +2,29 @@
import { GameCard } from "@/components/gameCard";
import { HomeLoggedInHeader } from "@/components/loggedInHeader";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Card, CardContent } from "@/components/ui/card";
import {
getOmniRecommendationsHome,
OmniRecommendation,
} from "@/lib/omniRecommendation";
import { getCookie } from "@/lib/roblox";
import { loadThumbnails, ThumbnailRequest } from "@/lib/thumbnailLoader";
import { loadThumbnails } from "@/lib/thumbnailLoader";
import { useEffect, useState } from "react";
export default function Home() {
const [rec, setRec] = useState<OmniRecommendation | null>(null);
const SORTS_ALLOWED_IDS = [100000003, 100000001];
const [rec, setRec] = useState<OmniRecommendation | null>(null);
useEffect(() => {
(async () => {
const r = await getOmniRecommendationsHome();
console.log("[ROBLOX]", "got omni recommendation from api", r);
let th: ThumbnailRequest[] = [];
r.sorts.filter(a=>SORTS_ALLOWED_IDS.includes(a.topicId)).forEach(b=>{
(b.recommendationList || []).forEach(c=>{
th.push({
type: "GameThumbnail",
targetId: r.contentMetadata.Game[c.contentId.toString()].rootPlaceId,
format: "webp",
size: "384x216"
})
})
});
setRec(r);
loadThumbnails(th).catch(a=>console.error(a))
loadThumbnails(
Object.entries(r.contentMetadata.Game).map((a) => ({
type: "GameThumbnail",
targetId: Number(a[1].rootPlaceId),
format: "webp",
size: "384x216",
}))
).catch((a) => {});
})();
}, []);
@@ -41,7 +35,7 @@ export default function Home() {
<CardContent className="p-4">
<div className="h-[200px] flex items-center justify-center">
<div className="animate-pulse text-muted-foreground">
Loading...
{"Loading..."}
</div>
</div>
</CardContent>
@@ -52,15 +46,13 @@ export default function Home() {
return (
<div className="overflow-scroll no-scrollbar w-screen max-h-screen h-screen">
<HomeLoggedInHeader/>
{"roblox in nextjs"}<br/>
<span className="font-mono">{"require(\"@/lib/roblox\").getCookie().length = "}{getCookie().length}{";"}</span>
<HomeLoggedInHeader />
<div className="p-4 space-y-8 no-scrollbar">
{rec.sorts
.filter((a) => SORTS_ALLOWED_IDS.includes(a.topicId))
.map((sort, idx) => (
<div key={idx}>
<h1 className="text-2xl">{sort.topic}</h1>
<h1 className="text-2xl pb-2">{sort.topic}</h1>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
{(sort.recommendationList || []).map(
(recommendation, idxb) => {
@@ -68,7 +60,9 @@ export default function Home() {
rec.contentMetadata.Game[
recommendation.contentId.toString()
];
return <GameCard key={idxb} game={game} />;
return (
<GameCard key={idxb} game={game} />
);
}
)}
</div>