summaryrefslogtreecommitdiff
path: root/app/api/contracts/get-template/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/api/contracts/get-template/route.ts')
-rw-r--r--app/api/contracts/get-template/route.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/api/contracts/get-template/route.ts b/app/api/contracts/get-template/route.ts
index ff42196f..b7965481 100644
--- a/app/api/contracts/get-template/route.ts
+++ b/app/api/contracts/get-template/route.ts
@@ -12,14 +12,18 @@ export async function POST(request: NextRequest) {
{ status: 400 }
);
}
+
+ // /api/files로 시작하는 경우 제거
+ const cleanPath = templatePath.startsWith('/api/files')
+ ? templatePath.slice('/api/files'.length)
+ : templatePath;
+
const isDev = process.env.NODE_ENV === 'development';
- const fullPath =
- isDev ?
- path.join(process.cwd(), `public`, templatePath)
- :
- path.join(`${process.env.NAS_PATH}`, templatePath);
-
+ const fullPath = isDev
+ ? path.join(process.cwd(), `public`, cleanPath)
+ : path.join(`${process.env.NAS_PATH}`, cleanPath);
+
const fileBuffer = await readFile(fullPath);
return new NextResponse(fileBuffer, {