mirror of
https://github.com/ld3z/new-manga.git
synced 2026-11-09 17:43:44 -07:00
fix search
This commit is contained in:
parent
86fa1d5a64
commit
daa059e667
2 changed files with 33 additions and 2 deletions
|
|
@ -125,8 +125,8 @@ const languages = [
|
|||
|
||||
const promises = [...slugs].map(async (slug) => {
|
||||
try {
|
||||
// Updated API endpoint to match ComicK's current structure
|
||||
const response = await fetch(`https://api.comick.fun/comic/${encodeURIComponent(slug)}`);
|
||||
// Use our API endpoint instead of direct ComicK API call
|
||||
const response = await fetch(`/api/comic/${encodeURIComponent(slug)}`);
|
||||
if (!response.ok) throw new Error('Comic not found');
|
||||
|
||||
const data = await response.json();
|
||||
|
|
|
|||
31
src/pages/api/comic/[slug].ts
Normal file
31
src/pages/api/comic/[slug].ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import type { APIRoute } from "astro";
|
||||
|
||||
export const GET: APIRoute = async ({ params }) => {
|
||||
const { slug } = params;
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://api.comick.fun/comic/${encodeURIComponent(slug!)}/`
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return new Response(JSON.stringify(data), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Comic fetch error:', error);
|
||||
return new Response(JSON.stringify({ error: 'Failed to fetch comic details' }), {
|
||||
status: 500,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue