Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating next package to 15.1.3 and added copyfiles in dev dependency #112

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions copy-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const fs = require("fs/promises");

async function copyFiles() {
try {
await fs.cp("public", ".next/standalone", { recursive: true });
await fs.cp(".next/static", ".next/standalone/.next/static", {
recursive: true,
});
} catch (err) {
console.error("Error copying files:", err);
return;
}
console.log("Files copied successfully.");
}

copyFiles();
7 changes: 3 additions & 4 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ export const config = {

export function middleware(request: NextRequest) {
const headers = new Headers(request.headers);
const x = headers.get("X-Forwarded-For");

headers.set("X-Forwarded-For", x ? `${x}, ${request.ip}` : request.ip!);
const xForwardedFor = headers.get("X-Forwarded-For");
const clientIp = xForwardedFor ? xForwardedFor.split(",")[0] : "";
headers.set("X-Forwarded-For", ` ${clientIp}`);
request.nextUrl.href = new URL("/api/event", process.env.PLAUSIBLE_HOST).href;

return NextResponse.rewrite(request.nextUrl, { request: { headers } });
}
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"private": true,
"scripts": {
"dev": "next",
"build": "next build && cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/static",
"build": "next build && node copy-files.ts",
"start": "node .next/standalone/server.js",
"lint": "eslint --ext ts,tsx .",
"lint:fix": "eslint --ext ts,tsx --fix ."
Expand All @@ -23,7 +23,7 @@
"classcat": "^5.0.5",
"elkjs": "^0.9.3",
"html-to-image": "^1.11.11",
"next": "^14.2.5",
"next": "^15.1.3",
"rambda": "^9.2.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
Loading
Loading