mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-04 07:19:52 +00:00
fix(studio): make optional file reads explicit (#883)
This commit is contained in:
@@ -108,8 +108,9 @@ export function useFileManager({
|
||||
const readOptionalProjectFile = useCallback(async (path: string): Promise<string> => {
|
||||
const pid = projectIdRef.current;
|
||||
if (!pid) throw new Error("No active project");
|
||||
const response = await fetch(`/api/projects/${pid}/files/${encodeURIComponent(path)}`);
|
||||
if (response.status === 404) return "";
|
||||
const response = await fetch(
|
||||
`/api/projects/${pid}/files/${encodeURIComponent(path)}?optional=1`,
|
||||
);
|
||||
if (!response.ok) throw new Error(`Failed to read ${path}`);
|
||||
const data = (await response.json()) as { content?: string };
|
||||
return typeof data.content === "string" ? data.content : "";
|
||||
|
||||
Reference in New Issue
Block a user