Compare commits
3 Commits
dev
...
feature/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edd5c1582b | ||
|
|
dff78b28a5 | ||
|
|
b4905ce4ee |
@@ -16,6 +16,8 @@ import { getPageKeywords, getBrandKeywords } from "@/lib/seo/keywords";
|
||||
import { Metadata } from "next";
|
||||
import Image from "next/image";
|
||||
|
||||
export const revalidate = 3600;
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }): Promise<Metadata> {
|
||||
|
||||
@@ -9,6 +9,8 @@ import { isValidLocale, DEFAULT_LOCALE, getSaleorLocale, type Locale } from "@/l
|
||||
import { getPageKeywords } from "@/lib/seo/keywords";
|
||||
import { Metadata } from "next";
|
||||
|
||||
export const revalidate = 3600;
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
||||
|
||||
interface ProductsPageProps {
|
||||
|
||||
65
src/app/api/op/track/route.ts
Normal file
65
src/app/api/op/track/route.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
const OPENPANEL_API_URL = process.env.OPENPANEL_API_URL || "https://op.nodecrew.me/api";
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.text();
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
"openpanel-client-id": process.env.NEXT_PUBLIC_OPENPANEL_CLIENT_ID || "",
|
||||
};
|
||||
|
||||
if (process.env.OPENPANEL_CLIENT_SECRET) {
|
||||
headers["openpanel-client-secret"] = process.env.OPENPANEL_CLIENT_SECRET;
|
||||
}
|
||||
|
||||
const response = await fetch(`${OPENPANEL_API_URL}/track`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
|
||||
const data = await response.text();
|
||||
return new NextResponse(data, {
|
||||
status: response.status,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("[OpenPanel Proxy] Error:", error);
|
||||
return new NextResponse(JSON.stringify({ error: "Proxy error" }), {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const url = new URL(request.url);
|
||||
const path = url.searchParams.get("path") || "";
|
||||
|
||||
try {
|
||||
const response = await fetch(`${OPENPANEL_API_URL}/track/${path}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"openpanel-client-id": process.env.NEXT_PUBLIC_OPENPANEL_CLIENT_ID || "",
|
||||
},
|
||||
});
|
||||
|
||||
const data = await response.text();
|
||||
return new NextResponse(data, {
|
||||
status: response.status,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("[OpenPanel Proxy] Error:", error);
|
||||
return new NextResponse(JSON.stringify({ error: "Proxy error" }), {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
}
|
||||
35
src/middleware.ts
Normal file
35
src/middleware.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
const response = NextResponse.next();
|
||||
|
||||
const url = request.nextUrl.pathname;
|
||||
|
||||
if (
|
||||
url.startsWith("/sr") ||
|
||||
url.startsWith("/en") ||
|
||||
url.startsWith("/de") ||
|
||||
url.startsWith("/fr") ||
|
||||
url === "/"
|
||||
) {
|
||||
if (
|
||||
!url.includes("/checkout") &&
|
||||
!url.includes("/cart") &&
|
||||
!url.includes("/api/")
|
||||
) {
|
||||
response.headers.set(
|
||||
"Cache-Control",
|
||||
"public, max-age=3600, stale-while-revalidate=86400"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
"/((?!_next/static|_next/image|favicon.ico|icon.png|robots.txt|sitemap.xml).*)",
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user