diff --git a/src/app/api/templates/[templateId]/route.js b/src/app/api/templates/[templateId]/route.js index c42ffc1..06aeb28 100644 --- a/src/app/api/templates/[templateId]/route.js +++ b/src/app/api/templates/[templateId]/route.js @@ -58,7 +58,7 @@ export async function PUT(request, { params }) { // Delete old file try { - const oldFilePath = path.join(process.cwd(), "public", existingTemplate.file_path); + const oldFilePath = path.join(process.cwd(), existingTemplate.file_path); await unlink(oldFilePath); } catch (fileError) { console.warn("Could not delete old template file:", fileError); @@ -67,10 +67,10 @@ export async function PUT(request, { params }) { // Save new file const fileExtension = path.extname(file.name); const fileName = `${Date.now()}-${Math.random().toString(36).substring(2)}${fileExtension}`; - const filePath = path.join(process.cwd(), "public", "templates", fileName); + const filePath = path.join(process.cwd(), "templates", fileName); // Ensure templates directory exists - const templatesDir = path.join(process.cwd(), "public", "templates"); + const templatesDir = path.join(process.cwd(), "templates"); try { await fs.promises.access(templatesDir); } catch { @@ -80,7 +80,7 @@ export async function PUT(request, { params }) { const buffer = Buffer.from(await file.arrayBuffer()); await fs.promises.writeFile(filePath, buffer); - updateData.file_path = `/templates/${fileName}`; + updateData.file_path = `templates/${fileName}`; updateData.original_filename = file.name; updateData.file_size = file.size; } diff --git a/src/app/api/templates/generate/route.js b/src/app/api/templates/generate/route.js index 2124929..c50da9e 100644 --- a/src/app/api/templates/generate/route.js +++ b/src/app/api/templates/generate/route.js @@ -65,7 +65,7 @@ export async function POST(request) { `).all(projectId); // Load template file - const templatePath = path.join(process.cwd(), "public", template.file_path); + const templatePath = path.join(process.cwd(), template.file_path); const templateContent = await readFile(templatePath); // Load the docx file as a binary