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