Rocky_Mountain_Vending/.pnpm-store/v10/files/7a/eab2809deca445d034f60ff41ea79888cfb318f1f2a044a4da79f39159c5fba9323d7d99d035f24525aa340eb1f9c9fc8be9f2a8a8575bb1e5bcf8c5952158
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

53 lines
No EOL
1.8 KiB
Text

import path from 'path';
import * as fs from 'fs/promises';
import { constants } from 'fs';
import * as Log from '../../../build/output/log';
import { middlewareResponse } from '../middleware-response';
const FONT_PREFIX = '/__nextjs_font/';
const VALID_FONTS = [
'geist-latin-ext.woff2',
'geist-mono-latin-ext.woff2',
'geist-latin.woff2',
'geist-mono-latin.woff2'
];
const FONT_HEADERS = {
'Content-Type': 'font/woff2',
'Cache-Control': 'public, max-age=31536000, immutable'
};
export function getDevOverlayFontMiddleware() {
return async function devOverlayFontMiddleware(req, res, next) {
try {
const { pathname } = new URL(`http://n${req.url}`);
if (!pathname.startsWith(FONT_PREFIX)) {
return next();
}
const fontFile = pathname.replace(FONT_PREFIX, '');
if (!VALID_FONTS.includes(fontFile)) {
return middlewareResponse.notFound(res);
}
const fontPath = path.resolve(__dirname, fontFile);
const fileExists = await checkFileExists(fontPath);
if (!fileExists) {
return middlewareResponse.notFound(res);
}
const fontData = await fs.readFile(fontPath);
Object.entries(FONT_HEADERS).forEach(([key, value])=>{
res.setHeader(key, value);
});
res.end(fontData);
} catch (err) {
Log.error('Failed to serve font:', err instanceof Error ? err.message : err);
return middlewareResponse.internalServerError(res);
}
};
}
async function checkFileExists(filePath) {
try {
await fs.access(filePath, constants.F_OK);
return true;
} catch {
return false;
}
}
//# sourceMappingURL=get-dev-overlay-font-middleware.js.map