тут нихуя не работает, ебаный рот этого казино
This commit is contained in:
19
frontend/style/app/api/cart/route.ts
Normal file
19
frontend/style/app/api/cart/route.ts
Normal 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' })
|
||||
}
|
||||
|
||||
12
frontend/style/app/api/disable-preview/route.ts
Normal file
12
frontend/style/app/api/disable-preview/route.ts
Normal 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))
|
||||
}
|
||||
|
||||
23
frontend/style/app/api/preview/route.ts
Normal file
23
frontend/style/app/api/preview/route.ts
Normal 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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user