тут нихуя не работает, ебаный рот этого казино

This commit is contained in:
User
2025-01-08 15:14:15 +03:00
parent 847102e843
commit 8c4c3f2e38
56 changed files with 1448 additions and 267 deletions

View File

@@ -0,0 +1,19 @@
import { NextRequest, NextResponse } from 'next/server'
import { getCart, saveCart, clearCart, CartItem } from '@/lib/cartStorage'
export async function GET() {
const cart = getCart()
return NextResponse.json(cart)
}
export async function POST(request: NextRequest) {
const cartItems: CartItem[] = await request.json()
saveCart(cartItems)
return NextResponse.json({ message: 'Cart updated successfully' })
}
export async function DELETE() {
clearCart()
return NextResponse.json({ message: 'Cart cleared successfully' })
}

View File

@@ -0,0 +1,12 @@
import { NextRequest, NextResponse } from 'next/server'
import { draftMode } from 'next/headers'
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url)
const id = searchParams.get('id')
draftMode().disable()
return NextResponse.redirect(new URL(`/product/${id}`, request.url))
}

View File

@@ -0,0 +1,23 @@
import { NextRequest, NextResponse } from 'next/server'
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url)
const secret = searchParams.get('secret')
const id = searchParams.get('id')
// Check the secret and next parameters
// This secret should be only known to this API route and the CMS
if (secret !== process.env.PREVIEW_SECRET || !id) {
return NextResponse.json({ message: 'Invalid token' }, { status: 401 })
}
// Enable Preview Mode by setting the cookies
const res = NextResponse.next()
res.cookies.set('__prerender_bypass', process.env.PRERENDER_BYPASS_TOKEN || '')
res.cookies.set('__next_preview_data', process.env.PREVIEW_DATA_TOKEN || '')
// Redirect to the path from the fetched post
// We don't redirect to searchParams.slug as that might lead to open redirect vulnerabilities
return NextResponse.redirect(new URL(`/product/${id}`, request.url))
}