mirror of
https://github.com/kyantech/Palmr.git
synced 2025-10-22 22:02:00 +00:00
feat: enhance API configuration and file handling for improved performance
- Added experimental server actions and increased body size limits in next.config.ts to support larger payloads. - Updated the download route to directly use the response body from the API, optimizing data handling. - Modified the upload route to utilize the request body directly and adjusted content length handling for better compatibility.
This commit is contained in:
@@ -16,6 +16,17 @@ const nextConfig: NextConfig = {
|
||||
],
|
||||
},
|
||||
serverExternalPackages: [],
|
||||
experimental: {
|
||||
serverActions: {
|
||||
bodySizeLimit: "1pb",
|
||||
},
|
||||
},
|
||||
api: {
|
||||
bodyParser: {
|
||||
sizeLimit: "1pb",
|
||||
},
|
||||
responseLimit: false,
|
||||
},
|
||||
};
|
||||
|
||||
const withNextIntl = createNextIntlPlugin();
|
||||
|
@@ -18,8 +18,7 @@ export async function GET(req: NextRequest, { params }: { params: Promise<{ toke
|
||||
const contentDisposition = apiRes.headers.get("Content-Disposition");
|
||||
const contentLength = apiRes.headers.get("Content-Length");
|
||||
|
||||
const resBody = await apiRes.arrayBuffer();
|
||||
const res = new NextResponse(resBody, {
|
||||
const res = new NextResponse(apiRes.body, {
|
||||
status: apiRes.status,
|
||||
headers: {
|
||||
"Content-Type": contentType,
|
||||
|
@@ -8,7 +8,6 @@ const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
|
||||
export async function PUT(req: NextRequest, { params }: { params: Promise<{ token: string }> }) {
|
||||
const { token } = await params;
|
||||
const cookieHeader = req.headers.get("cookie");
|
||||
const body = await req.arrayBuffer();
|
||||
const url = `${API_BASE_URL}/filesystem/upload/${token}`;
|
||||
|
||||
const apiRes = await fetch(url, {
|
||||
@@ -16,10 +15,11 @@ export async function PUT(req: NextRequest, { params }: { params: Promise<{ toke
|
||||
headers: {
|
||||
cookie: cookieHeader || "",
|
||||
"Content-Type": req.headers.get("Content-Type") || "application/octet-stream",
|
||||
"Content-Length": req.headers.get("Content-Length") || body.byteLength.toString(),
|
||||
"Content-Length": req.headers.get("Content-Length") || "0",
|
||||
},
|
||||
body: body,
|
||||
});
|
||||
body: req.body,
|
||||
duplex: "half",
|
||||
} as RequestInit);
|
||||
|
||||
const contentType = apiRes.headers.get("Content-Type") || "application/json";
|
||||
|
||||
|
Reference in New Issue
Block a user