mirror of
https://github.com/ld3z/new-manga.git
synced 2026-11-09 21:03:45 -07:00
fix?
This commit is contained in:
parent
94c02124f2
commit
859f839b66
3 changed files with 54 additions and 5 deletions
32
package-lock.json
generated
32
package-lock.json
generated
|
|
@ -12,6 +12,7 @@
|
||||||
"@astrojs/tailwind": "^6.0.2",
|
"@astrojs/tailwind": "^6.0.2",
|
||||||
"@astrojs/vercel": "^8.1.4",
|
"@astrojs/vercel": "^8.1.4",
|
||||||
"@floating-ui/dom": "^1.6.13",
|
"@floating-ui/dom": "^1.6.13",
|
||||||
|
"@sparticuz/chromium": "^133.0.0",
|
||||||
"@types/node": "^22.15.3",
|
"@types/node": "^22.15.3",
|
||||||
"@vercel/analytics": "^1.5.0",
|
"@vercel/analytics": "^1.5.0",
|
||||||
"astro": "^5.7.10",
|
"astro": "^5.7.10",
|
||||||
|
|
@ -1474,6 +1475,18 @@
|
||||||
"resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz",
|
||||||
"integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="
|
"integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@sparticuz/chromium": {
|
||||||
|
"version": "133.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-133.0.0.tgz",
|
||||||
|
"integrity": "sha512-wioNxMtSxRI+Y6ymc/UFPX9lY7A1SDgBezjFITH6arwe5CONfWosNDGpgflUGYajxxGktb1k3kjJ83jWzbccBw==",
|
||||||
|
"dependencies": {
|
||||||
|
"follow-redirects": "^1.15.9",
|
||||||
|
"tar-fs": "^3.0.8"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 16"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@swc/helpers": {
|
"node_modules/@swc/helpers": {
|
||||||
"version": "0.5.17",
|
"version": "0.5.17",
|
||||||
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz",
|
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz",
|
||||||
|
|
@ -3313,6 +3326,25 @@
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/follow-redirects": {
|
||||||
|
"version": "1.15.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
||||||
|
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"debug": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fontkit": {
|
"node_modules/fontkit": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/fontkit/-/fontkit-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/fontkit/-/fontkit-2.0.4.tgz",
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
"@astrojs/tailwind": "^6.0.2",
|
"@astrojs/tailwind": "^6.0.2",
|
||||||
"@astrojs/vercel": "^8.1.4",
|
"@astrojs/vercel": "^8.1.4",
|
||||||
"@floating-ui/dom": "^1.6.13",
|
"@floating-ui/dom": "^1.6.13",
|
||||||
|
"@sparticuz/chromium": "^133.0.0",
|
||||||
"@types/node": "^22.15.3",
|
"@types/node": "^22.15.3",
|
||||||
"@vercel/analytics": "^1.5.0",
|
"@vercel/analytics": "^1.5.0",
|
||||||
"astro": "^5.7.10",
|
"astro": "^5.7.10",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import type { APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import chromium from 'chrome-aws-lambda';
|
|
||||||
import puppeteerCore from 'puppeteer-core';
|
import puppeteerCore from 'puppeteer-core';
|
||||||
|
|
||||||
|
// Import @sparticuz/chromium for better serverless compatibility
|
||||||
|
import chromium from '@sparticuz/chromium';
|
||||||
|
|
||||||
// Check if running on Vercel
|
// Check if running on Vercel
|
||||||
const IS_VERCEL = process.env.VERCEL === '1' || process.env.VERCEL === 'true';
|
const IS_VERCEL = process.env.VERCEL === '1' || process.env.VERCEL === 'true';
|
||||||
|
|
||||||
|
|
@ -16,13 +18,17 @@ async function scrapeComicList(userId: string, limit: number = 10): Promise<stri
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
if (IS_VERCEL) {
|
if (IS_VERCEL) {
|
||||||
// Use chrome-aws-lambda for Vercel environment
|
// Use @sparticuz/chromium which is optimized for serverless environments
|
||||||
console.log('Running on Vercel - using chrome-aws-lambda');
|
console.log('Running on Vercel - using @sparticuz/chromium with serverless settings');
|
||||||
|
|
||||||
|
// Configure @sparticuz/chromium for Vercel
|
||||||
|
await chromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');
|
||||||
|
|
||||||
browser = await puppeteerCore.launch({
|
browser = await puppeteerCore.launch({
|
||||||
args: chromium.args,
|
args: chromium.args,
|
||||||
defaultViewport: chromium.defaultViewport,
|
defaultViewport: chromium.defaultViewport,
|
||||||
executablePath: await chromium.executablePath,
|
executablePath: await chromium.executablePath(), // Note: this is now a function call
|
||||||
headless: chromium.headless,
|
headless: true, // Always use headless mode in serverless environment
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -173,6 +179,16 @@ export const GET: APIRoute = async ({ request }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Log environment information for debugging
|
||||||
|
console.log(`Environment: ${IS_VERCEL ? 'Vercel' : 'Local'}`);
|
||||||
|
if (IS_VERCEL) {
|
||||||
|
try {
|
||||||
|
console.log('Chrome executable path:', await chromium.executablePath());
|
||||||
|
console.log('Chrome args:', chromium.args);
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Error getting Chrome executable path:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const userId = url.searchParams.get('userId');
|
const userId = url.searchParams.get('userId');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue