- Add /api/v1/ and /files/ rewrite rules in next.config.ts so frontend can call backend without /admin139 prefix - Fix upload using MultiPartParser instead of req->getUploadedFiles() - Add client-side image compression (canvas resize to 1920px, quality 0.8) for photos >500KB before upload - Safe JSON parsing: catch HTML error responses instead of throwing SyntaxError on non-JSON backend responses - Fix backslash escape in delete filename validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
36 行
1.1 KiB
TypeScript
36 行
1.1 KiB
TypeScript
import type { NextConfig } from "next";
|
|
|
|
const nextConfig: NextConfig = {
|
|
// For local dev convenience. In production you should configure reverse proxy
|
|
// and set NEXT_PUBLIC_API_BASE to your public API origin.
|
|
async rewrites() {
|
|
// Reverse proxy backend under a path prefix, so browser can access backend
|
|
// with same-origin (no CORS): http://<host>:7888/admin139/...
|
|
const backendInternal =
|
|
process.env.BACKEND_INTERNAL_URL ??
|
|
(process.env.NODE_ENV === "development"
|
|
? "http://127.0.0.1:8080"
|
|
: "http://backend:8080");
|
|
|
|
return [
|
|
{
|
|
// Keep /admin139 as frontend admin entry page, only proxy nested API paths.
|
|
source: "/admin139/:path+",
|
|
destination: `${backendInternal}/:path*`,
|
|
},
|
|
{
|
|
// Proxy backend API calls made without /admin139 prefix
|
|
source: "/api/v1/:path*",
|
|
destination: `${backendInternal}/api/v1/:path*`,
|
|
},
|
|
{
|
|
// Proxy backend static files (note images etc.)
|
|
source: "/files/:path*",
|
|
destination: `${backendInternal}/files/:path*`,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|