Fix font buffer slice and env var access for production SSR
Node.js Buffer pool shares an ArrayBuffer — slice to give Satori's OpenType parser a standalone copy starting at byte 0. Use process.env instead of import.meta.env for BACKEND_INTERNAL_URL since Vite only exposes PUBLIC_* prefixed vars via import.meta.env.
This commit is contained in:
parent
ea66086b44
commit
db2ecf32c4
@ -17,7 +17,10 @@ function loadFont(): ArrayBuffer {
|
|||||||
];
|
];
|
||||||
for (const path of candidates) {
|
for (const path of candidates) {
|
||||||
try {
|
try {
|
||||||
return readFileSync(path).buffer as ArrayBuffer;
|
const buf = readFileSync(path);
|
||||||
|
// Node.js Buffers share a pooled ArrayBuffer — slice to get a
|
||||||
|
// standalone copy so Satori's OpenType parser starts at byte 0.
|
||||||
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
||||||
} catch {
|
} catch {
|
||||||
// try next
|
// try next
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
|
// process.env is required here — Vite's import.meta.env only exposes
|
||||||
|
// PUBLIC_* prefixed vars. This module runs server-side only (SSR).
|
||||||
export const INTERNAL_API_BASE =
|
export const INTERNAL_API_BASE =
|
||||||
import.meta.env.BACKEND_INTERNAL_URL || 'http://localhost:8099';
|
process.env.BACKEND_INTERNAL_URL || 'http://localhost:8099';
|
||||||
|
|
||||||
export async function fetchNotebookMeta(id: string) {
|
export async function fetchNotebookMeta(id: string) {
|
||||||
const url = `${INTERNAL_API_BASE}/api/notebooks/${encodeURIComponent(id)}`;
|
const url = `${INTERNAL_API_BASE}/api/notebooks/${encodeURIComponent(id)}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user