diff --git a/app/api/feed/route.ts b/app/api/feed/route.ts index b8163f7a..fa140beb 100644 --- a/app/api/feed/route.ts +++ b/app/api/feed/route.ts @@ -1,11 +1,15 @@ import postgres from '@/lib/postgres' import { NextRequest, NextResponse } from 'next/server' -export async function POST(req: NextRequest) { - const { page = 0, tag, id } = await req.json() - if (!id) { +export async function GET(req: NextRequest) { + const pageString = req.nextUrl.searchParams.get('page') || 0 + const page = Number(pageString) + const tag = req.nextUrl.searchParams.get('tag') + const idString = req.nextUrl.searchParams.get('id') + if (!idString) { return NextResponse.json({ error: 'No user found' }, { status: 500 }) } + const id = Number(idString) if (tag) { const postTags = await postgres.postTag.findMany({ select: { postId: true }, diff --git a/app/api/session/route.ts b/app/api/session/route.ts index 6b330957..a656a19e 100644 --- a/app/api/session/route.ts +++ b/app/api/session/route.ts @@ -1,6 +1,5 @@ import { config } from "@/app/auth"; import postgres from "@/lib/postgres"; -import { getServerSession } from "next-auth"; import { NextRequest, NextResponse } from "next/server"; export async function POST(req: NextRequest) { @@ -15,22 +14,12 @@ export async function POST(req: NextRequest) { include: { Followers: { include: { - follower: { - include: { - Followers: true, - Followings: true, - }, - }, + follower: true, }, }, Followings: { include: { - following: { - include: { - Followers: true, - Followings: true, - }, - }, + following: true, }, }, bookmarks: { @@ -42,7 +31,6 @@ export async function POST(req: NextRequest) { } } }, - posts: true, notifications: true, settings: true, tagfollower: { diff --git a/components/feed/get-feed.ts b/components/feed/get-feed.ts index 41fd4e22..f836b3dc 100644 --- a/components/feed/get-feed.ts +++ b/components/feed/get-feed.ts @@ -5,13 +5,10 @@ import { getSessionUser } from "../get-session-user"; export const fetchFeed = async ({ page = 0, tag }: { page?: number, tag?: string | undefined }) => { const user = await getSessionUser(); - const result = await fetch(process.env.DOMAIN + "/api/feed", { - method: "POST", - body: JSON.stringify({ page, tag, id: user?.id }), - headers: { - "Content-Type": "application/json", + const result = await fetch(process.env.DOMAIN + "/api/feed?page=" + page + "?tag=" + "?id=" + user?.id , { + method: "GET", }, - }).then((res) => res.json()); + ).then((res) => res.json()); return result?.feed; } \ No newline at end of file