fix(nextjs): Handle missing directory paths in API routes
This commit is contained in:
parent
d48d5ac28f
commit
18f3466258
5 changed files with 42 additions and 24 deletions
|
|
@ -24,7 +24,7 @@ ENV TEMP_DIRECTORY=/tmp/presenton
|
|||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
||||
|
||||
# Install ollama
|
||||
RUN curl -fsSL http://ollama.com/install.sh | sh
|
||||
# RUN curl -fsSL http://ollama.com/install.sh | sh
|
||||
|
||||
# Install dependencies for FastAPI
|
||||
RUN pip install aiohttp aiomysql aiosqlite asyncpg fastapi[standard] \
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import {
|
|||
SquareArrowOutUpRight,
|
||||
Play,
|
||||
Loader2,
|
||||
Redo2 ,
|
||||
Redo2,
|
||||
Undo2,
|
||||
RefreshCcw,
|
||||
|
||||
} from "lucide-react";
|
||||
import React, { useState } from "react";
|
||||
import Wrapper from "@/components/Wrapper";
|
||||
|
|
@ -73,8 +73,6 @@ const Header = ({
|
|||
// Save the presentation data before exporting
|
||||
trackEvent(MixpanelEvent.Header_UpdatePresentationContent_API_Call);
|
||||
await PresentationGenerationApi.updatePresentationContent(presentationData);
|
||||
|
||||
|
||||
trackEvent(MixpanelEvent.Header_GetPptxModel_API_Call);
|
||||
const pptx_model = await get_presentation_pptx_model(presentation_id);
|
||||
if (!pptx_model) {
|
||||
|
|
@ -188,28 +186,28 @@ const Header = ({
|
|||
<div className="flex flex-col lg:flex-row items-center gap-4">
|
||||
{/* undo redo */}
|
||||
<button onClick={handleReGenerate} disabled={isStreaming || !presentationData} className="text-white disabled:opacity-50" >
|
||||
|
||||
|
||||
Re-Generate
|
||||
</button>
|
||||
<div className="flex items-center gap-2 ">
|
||||
<ToolTip content="Undo">
|
||||
<button disabled={!canUndo} className="text-white disabled:opacity-50" onClick={() => {
|
||||
onUndo();
|
||||
}}>
|
||||
<button disabled={!canUndo} className="text-white disabled:opacity-50" onClick={() => {
|
||||
onUndo();
|
||||
}}>
|
||||
|
||||
<Undo2 className="w-6 h-6 " />
|
||||
|
||||
</button>
|
||||
</ToolTip>
|
||||
<ToolTip content="Redo">
|
||||
<Undo2 className="w-6 h-6 " />
|
||||
|
||||
<button disabled={!canRedo} className="text-white disabled:opacity-50" onClick={() => {
|
||||
onRedo();
|
||||
}}>
|
||||
<Redo2 className="w-6 h-6 " />
|
||||
|
||||
</button>
|
||||
</ToolTip>
|
||||
</button>
|
||||
</ToolTip>
|
||||
<ToolTip content="Redo">
|
||||
|
||||
<button disabled={!canRedo} className="text-white disabled:opacity-50" onClick={() => {
|
||||
onRedo();
|
||||
}}>
|
||||
<Redo2 className="w-6 h-6 " />
|
||||
|
||||
</button>
|
||||
</ToolTip>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -81,8 +81,15 @@ export async function POST(req: NextRequest) {
|
|||
browser.close();
|
||||
|
||||
const sanitizedTitle = sanitizeFilename(title ?? "presentation");
|
||||
const appDataDirectory = process.env.APP_DATA_DIRECTORY!;
|
||||
if (!appDataDirectory) {
|
||||
return NextResponse.json({
|
||||
error: "App data directory not found",
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
const destinationPath = path.join(
|
||||
process.env.APP_DATA_DIRECTORY!,
|
||||
appDataDirectory,
|
||||
"exports",
|
||||
`${sanitizedTitle}.pdf`
|
||||
);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,16 @@ export async function POST(request: NextRequest) {
|
|||
const bytes = await file.arrayBuffer();
|
||||
const buffer = Buffer.from(bytes);
|
||||
|
||||
if (!userDataDir) {
|
||||
return NextResponse.json(
|
||||
{ error: "User data directory not found" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
// Create uploads directory if it doesn't exist
|
||||
const uploadsDir = path.join(userDataDir, "uploads");
|
||||
fs.mkdirSync(uploadsDir, { recursive: true });
|
||||
|
||||
|
||||
|
||||
// Generate unique filename
|
||||
const filename = `${crypto.randomBytes(16).toString("hex")}.png`;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,18 @@ import { LLMConfig } from "@/types/llm_config";
|
|||
|
||||
const userConfigPath = process.env.USER_CONFIG_PATH!;
|
||||
const canChangeKeys = process.env.CAN_CHANGE_KEYS !== "false";
|
||||
console.log("UserConfigPath:", userConfigPath);
|
||||
|
||||
export async function GET() {
|
||||
if (!canChangeKeys) {
|
||||
return NextResponse.json({
|
||||
error: "You are not allowed to access this resource",
|
||||
status: 403,
|
||||
});
|
||||
}
|
||||
if (!userConfigPath) {
|
||||
return NextResponse.json({
|
||||
error: "User config path not found",
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue