Add categories

This commit is contained in:
2025-05-28 10:24:53 +00:00
parent 37764dce4d
commit f7f65c4e2c
12 changed files with 1104 additions and 339 deletions

View File

@@ -1,45 +1,45 @@
import { NextResponse } from 'next/server';
import { headers } from 'next/headers';
export async function GET(
request: Request,
{ params }: { params: { id: string } }
) {
try {
const headersList = headers();
const response = await fetch(
`https://neomovies-api.vercel.app/movies/${params.id}/external-ids`,
{
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
);
const data = await response.json();
// Создаем новый Response с нужными заголовками
return new NextResponse(JSON.stringify(data), {
status: 200,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization'
}
});
} catch (error) {
console.error('Error fetching external IDs:', error);
return new NextResponse(
JSON.stringify({ error: 'Failed to fetch external IDs' }),
{
status: 500,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
}
}
);
}
}
import { NextResponse } from 'next/server';
import { headers } from 'next/headers';
export async function GET(
request: Request,
{ params }: { params: { id: string } }
) {
try {
const headersList = headers();
const response = await fetch(
`https://neomovies-api.vercel.app/movies/${params.id}/external-ids`,
{
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
);
const data = await response.json();
// Создаем новый Response с нужными заголовками
return new NextResponse(JSON.stringify(data), {
status: 200,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization'
}
});
} catch (error) {
console.error('Error fetching external IDs:', error);
return new NextResponse(
JSON.stringify({ error: 'Failed to fetch external IDs' }),
{
status: 500,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
}
}
);
}
}