Fix Share Card missing logo: Switch from Edge to Node.js runtime and embed logo directly as base64 via fs

This commit is contained in:
2026-09-22 19:17:59 +05:30
parent e789ea21d3
commit 1b1a006d41

View File

@@ -1,7 +1,7 @@
import { ImageResponse } from 'next/og';
import { NextRequest } from 'next/server';
export const runtime = 'edge';
import { join } from 'path';
import { readFileSync } from 'fs';
export async function GET(req: NextRequest) {
try {
@@ -18,10 +18,11 @@ export async function GET(req: NextRequest) {
const target = searchParams.get('target') || 'JEE';
const plan = searchParams.get('plan') || 'Free';
// Build absolute URL for the logo
const protocol = req.headers.get('x-forwarded-proto') || 'http';
const host = req.headers.get('host') || 'localhost:3000';
const logoUrl = `${protocol}://${host}/PragatiVeer_Logo/PNG_Logos/Rectangular_dark_background.png`;
// Load logo from disk and convert to base64
const logoPath = join(process.cwd(), 'public', 'PragatiVeer_Logo', 'PNG_Logos', 'Rectangular_dark_background.png');
const logoData = readFileSync(logoPath);
const logoBase64 = logoData.toString('base64');
const logoUrl = `data:image/png;base64,${logoBase64}`;
return new ImageResponse(
(