1.4-1.6: add rewrites, remove BFF handlers, update client to use relative URLs

This commit is contained in:
parsa aghaei 2026-06-23 18:20:00 +03:30
parent 54a4f5564b
commit 3a0c5746b7
7 changed files with 14 additions and 41 deletions

View File

@ -15,7 +15,18 @@ const nextConfig = {
},
],
},
// سایر تنظیمات Next.js شما
async rewrites() {
return [
{
source: '/api/website/:path*',
destination: `${process.env.NEXT_PUBLIC_BACK_URL}/api/website/:path*`,
},
{
source: '/api/blog/:path*',
destination: `${process.env.NEXT_PUBLIC_BACK_URL}/api/blog/:path*`,
},
];
},
webpack(config, { isServer }) {
if (!isServer) {
config.optimization.splitChunks = {

View File

@ -47,7 +47,7 @@ export default function Projects({ dict }: MyProjectsProps) {
);
const fetchProjects = async () => {
const res = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/website/projects/translation/${locale}?sort=desc&per_page=40`,
`/api/website/projects/translation/${locale}?sort=desc&per_page=40`,
);
const data = await res.json();
const resProjects: Project[] =

View File

@ -29,7 +29,7 @@ export default function Services({ dict }: ServicesProps) {
const fetchServices = async () => {
setLoading(true);
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/website/services/${getCookie("selectedLocale") !== undefined ? getCookie("selectedLocale") : getCookie("defaultLocale")}`,
`/api/website/services/${getCookie("selectedLocale") !== undefined ? getCookie("selectedLocale") : getCookie("defaultLocale")}`,
).then((res) => res.json());
setServices(response);

View File

@ -1,9 +0,0 @@
import { NextResponse } from "next/server";
export async function GET() {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/blog/homepage`, {
cache: "no-store" // غیرفعال کردن کش
});
const data = await response.json();
return NextResponse.json(data);
}

View File

@ -1,9 +0,0 @@
import { NextResponse } from "next/server";
export async function GET() {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/about-me`, {
cache: "no-store" // غیرفعال کردن کش
});
const data = await response.json();
return NextResponse.json(data);
}

View File

@ -1,9 +0,0 @@
import { NextResponse } from "next/server";
export async function GET() {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/projects`, {
cache: "no-store" // غیرفعال کردن کش
});
const data = await response.json();
return NextResponse.json(data);
}

View File

@ -1,11 +0,0 @@
import { NextResponse } from "next/server";
export async function GET() {
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/services`, {
cache: "no-store", // غیرفعال کردن کش
});
const services = await res.json();
return NextResponse.json(services);
}