feat(perf): implement comprehensive Core Web Vitals, ISR caching, and media optimizations
Deploy Canina / deploy (push) Successful in 1m48s
Deploy Canina / deploy (push) Successful in 1m48s
This commit is contained in:
1 parent
2a31a9f8e4
commit
fe6a900665
42 files changed
+12941
-10561
No files matched your search
@@ -6,11 +6,13 @@ import Footer from "../components/Footer";
|
||||
import { NetworkBanner } from "../components/NetworkBanner";
|
||||
import { Toaster, toast } from "sonner";
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
const CartDrawer = dynamic(() => import("../components/CartDrawer"), { ssr: false });
|
||||
const LoginModal = dynamic(() => import("../components/LoginModal"), { ssr: false });
|
||||
const AuthModal = dynamic(() => import("../components/AuthModal"), { ssr: false });
|
||||
const B2BPortal = dynamic(() => import("../components/B2BPortal"), { ssr: false });
|
||||
|
||||
import CartDrawer from "../components/CartDrawer";
|
||||
import LoginModal from "../components/LoginModal";
|
||||
import AuthModal from "../components/AuthModal";
|
||||
import B2BPortal from "../components/B2BPortal";
|
||||
import { useUserStore } from "../lib/store/userStore";
|
||||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||
import { useUIStore } from "../lib/store/uiStore";
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { revalidateTag, revalidatePath } from 'next/cache';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
return handleRevalidate(request);
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
return handleRevalidate(request);
|
||||
}
|
||||
|
||||
async function handleRevalidate(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
let secret = searchParams.get('secret') || request.headers.get('x-revalidate-secret');
|
||||
let tag = searchParams.get('tag');
|
||||
let path = searchParams.get('path');
|
||||
|
||||
// Check auth header if bearer token provided
|
||||
const authHeader = request.headers.get('authorization');
|
||||
if (authHeader && authHeader.startsWith('Bearer ')) {
|
||||
secret = authHeader.substring(7);
|
||||
}
|
||||
|
||||
if (request.method === 'POST') {
|
||||
try {
|
||||
const body = await request.json().catch(() => ({}));
|
||||
if (body && typeof body === 'object') {
|
||||
if (body.secret) secret = body.secret;
|
||||
if (body.tag) tag = body.tag;
|
||||
if (body.path) path = body.path;
|
||||
}
|
||||
} catch {
|
||||
// Ignore body read error
|
||||
}
|
||||
}
|
||||
|
||||
const expectedSecret = process.env.REVALIDATION_SECRET || 'canina_revalidation_secret_key_2026';
|
||||
if (!secret || secret !== expectedSecret) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: 'Invalid revalidation secret token' },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
if (!tag && !path) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: 'Missing tag or path parameter for cache revalidation' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const revalidated: { tag?: string; path?: string } = {};
|
||||
|
||||
if (tag) {
|
||||
revalidateTag(tag, 'default');
|
||||
revalidated.tag = tag;
|
||||
}
|
||||
|
||||
if (path) {
|
||||
revalidatePath(path);
|
||||
revalidated.path = path;
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
revalidated: true,
|
||||
...revalidated,
|
||||
now: Date.now(),
|
||||
});
|
||||
}
|
||||
@@ -24,7 +24,12 @@ async function getBlog(rawSlug: string) {
|
||||
const slug = decodeURIComponent(rawSlug);
|
||||
const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api';
|
||||
const apiBase = apiUrl.endsWith('/api') ? apiUrl : `${apiUrl.replace(/\/$/, '')}/api`;
|
||||
const res = await fetch(`${apiBase}/blogs/${encodeURIComponent(slug)}`, { next: { revalidate: 60 } });
|
||||
const res = await fetch(`${apiBase}/blogs/${encodeURIComponent(slug)}`, {
|
||||
next: {
|
||||
tags: ['blogs', `blog-${slug}`],
|
||||
revalidate: 3600,
|
||||
},
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.error(`[Blog] Failed to fetch blog ${slug}: ${res.status}`);
|
||||
return null;
|
||||
@@ -37,7 +42,7 @@ async function getBlog(rawSlug: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export const revalidate = 60;
|
||||
export const revalidate = 3600;
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
@@ -301,9 +306,10 @@ export default async function BlogPostPage({ params }: { params: Promise<{ slug:
|
||||
src={blog.imageUrl}
|
||||
alt={blog.imageAlt || blog.title}
|
||||
fill
|
||||
priority
|
||||
sizes="(max-width: 1024px) 100vw, 800px"
|
||||
className="w-full h-full object-cover"
|
||||
unoptimized
|
||||
priority
|
||||
/>
|
||||
{blog.imageCaption && (
|
||||
<div className="absolute bottom-0 inset-x-0 bg-black/60 backdrop-blur-sm text-white text-xs font-medium py-2 px-4 text-center">
|
||||
|
||||
@@ -10,11 +10,15 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
});
|
||||
}
|
||||
|
||||
export const revalidate = 3600;
|
||||
|
||||
async function getCategories() {
|
||||
const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api';
|
||||
const apiBase = apiUrl.endsWith('/api') ? apiUrl : `${apiUrl.replace(/\/$/, '')}/api`;
|
||||
try {
|
||||
const res = await fetch(`${apiBase}/blogs/categories`, { next: { revalidate: 60 } });
|
||||
const res = await fetch(`${apiBase}/blogs/categories`, {
|
||||
next: { tags: ['blogs', 'blog-categories'], revalidate: 3600 },
|
||||
});
|
||||
if (!res.ok) return [];
|
||||
const json = await res.json();
|
||||
return json.data || json || [];
|
||||
@@ -28,7 +32,9 @@ async function getBlogs() {
|
||||
const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api';
|
||||
const apiBase = apiUrl.endsWith('/api') ? apiUrl : `${apiUrl.replace(/\/$/, '')}/api`;
|
||||
try {
|
||||
const res = await fetch(`${apiBase}/blogs?limit=50`, { next: { revalidate: 60 } });
|
||||
const res = await fetch(`${apiBase}/blogs?limit=50`, {
|
||||
next: { tags: ['blogs'], revalidate: 3600 },
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.error(`[Blog] Failed to fetch blogs: ${res.status}`);
|
||||
return [];
|
||||
|
||||
@@ -70,13 +70,13 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--font-sans: "Vazirmatn";
|
||||
--font-vazir: "Vazirmatn";
|
||||
--font-shabnam: "Shabnam";
|
||||
--font-sahel: "Sahel";
|
||||
--font-lalezar: "Lalezar", cursive;
|
||||
--font-sans: var(--font-vazir), "Vazirmatn", system-ui, sans-serif;
|
||||
--font-vazir: var(--font-vazir), "Vazirmatn", sans-serif;
|
||||
--font-shabnam: "Shabnam", sans-serif;
|
||||
--font-sahel: "Sahel", sans-serif;
|
||||
--font-lalezar: var(--font-lalezar), "Lalezar", cursive;
|
||||
--font-nastaliq: "IranNastaliq", serif;
|
||||
--font-iranian-sans: "IranianSans";
|
||||
--font-iranian-sans: "IranianSans", sans-serif;
|
||||
|
||||
/* Brand Colors */
|
||||
--color-canina-blue: #1E4053;
|
||||
@@ -99,11 +99,11 @@
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
font-family: "Vazirmatn" !important;
|
||||
font-family: var(--font-vazir), "Vazirmatn", sans-serif !important;
|
||||
}
|
||||
|
||||
html, body {
|
||||
font-family: "Vazirmatn" !important;
|
||||
font-family: var(--font-vazir), "Vazirmatn", sans-serif !important;
|
||||
@apply bg-medical-gray-50 text-medical-gray-900 antialiased max-w-[100vw] overflow-x-hidden;
|
||||
font-feature-settings: "ss01", "ss02", "cv01", "cv11";
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Metadata } from 'next';
|
||||
import './globals.css';
|
||||
import ClientLayout from './ClientLayout';
|
||||
import { getSeoConfig } from '../lib/seo';
|
||||
import { vazirmatn, lalezar } from '../lib/fonts';
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const config = await getSeoConfig();
|
||||
@@ -118,7 +119,7 @@ export default function RootLayout({
|
||||
const safeJsonLd = JSON.stringify(jsonLd).replace(/</g, '\\u003c');
|
||||
|
||||
return (
|
||||
<html lang="fa" dir="rtl" suppressHydrationWarning>
|
||||
<html lang="fa" dir="rtl" className={`${vazirmatn.variable} ${lalezar.variable}`} suppressHydrationWarning>
|
||||
<body className="min-h-screen bg-medical-gray-50 font-sans" suppressHydrationWarning>
|
||||
<script
|
||||
type="application/ld+json"
|
||||
|
||||
@@ -4,6 +4,8 @@ import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
import { getSeoConfig, formatPageTitle } from "../../../lib/seo";
|
||||
|
||||
export const revalidate = 3600;
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params }: { params: Promise<{ slug: string }> }
|
||||
): Promise<Metadata> {
|
||||
@@ -117,8 +119,9 @@ export default async function ShopProductPage({ params }: { params: Promise<{ sl
|
||||
...(product.images || [])
|
||||
])).filter(Boolean) as string[];
|
||||
|
||||
// 1 year valid price offer
|
||||
const priceValidUntil = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
||||
// 1 year valid price offer based on product timestamp
|
||||
const baseTime = product.updatedAt ? new Date(product.updatedAt).getTime() : 1771939200000;
|
||||
const priceValidUntil = new Date(baseTime + 365 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
||||
|
||||
// Process approved reviews and ratings
|
||||
const approvedReviews = (product.reviews || []).filter(r => r.status === 'APPROVED' || !r.status);
|
||||
|
||||
@@ -128,7 +128,13 @@ const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) => {
|
||||
)}
|
||||
|
||||
<div className="aspect-square bg-medical-gray-50 flex items-center justify-center p-8 overflow-hidden relative">
|
||||
<SafeImage src={product.image} alt={product.name} className="w-full h-full group-hover:scale-110 transition-transform duration-700" imgClassName="object-contain" />
|
||||
<SafeImage
|
||||
src={product.image}
|
||||
alt={product.name}
|
||||
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 25vw)"
|
||||
className="w-full h-full group-hover:scale-110 transition-transform duration-700"
|
||||
imgClassName="object-contain"
|
||||
/>
|
||||
<div className="absolute bottom-4 left-4 flex gap-2">
|
||||
{(product.suitableFor === "سگ" || product.suitableFor === "هر دو") && (
|
||||
<div className="w-7 h-7 bg-white rounded-lg flex items-center justify-center text-medical-gray-400 border border-medical-gray-100 shadow-sm">
|
||||
|
||||
@@ -245,6 +245,8 @@ export default function BlogPage({
|
||||
src={featuredPost.image}
|
||||
alt={featuredPost.imageAlt || featuredPost.title}
|
||||
fill
|
||||
priority
|
||||
sizes="(max-width: 1024px) 100vw, 50vw"
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"
|
||||
unoptimized
|
||||
/>
|
||||
@@ -314,6 +316,7 @@ export default function BlogPage({
|
||||
src={post.image}
|
||||
alt={post.imageAlt || post.title}
|
||||
fill
|
||||
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
||||
className="w-full h-full object-cover group-hover:scale-108 transition-transform duration-700"
|
||||
unoptimized
|
||||
/>
|
||||
|
||||
@@ -122,11 +122,13 @@ export default function BlogPreviewSection() {
|
||||
transition={{ delay: idx * 0.1 }}
|
||||
className="bg-medical-gray-50/60 rounded-[2rem] border border-medical-gray-100 overflow-hidden hover:shadow-lg hover:-translate-y-1 transition-all flex flex-col group"
|
||||
>
|
||||
<Link href={`/blog/${blog.slug}`} className="block relative h-52 overflow-hidden bg-medical-gray-100">
|
||||
<Link href={`/blog/${blog.slug}`} className="block relative aspect-video w-full overflow-hidden bg-medical-gray-100">
|
||||
<SafeImage
|
||||
src={image}
|
||||
alt={blog.title}
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"
|
||||
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
||||
className="w-full h-full"
|
||||
imgClassName="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"
|
||||
/>
|
||||
</Link>
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ function ProductCard({ product }: { product: Product }) {
|
||||
<SafeImage
|
||||
src={product.image}
|
||||
alt={nameFa}
|
||||
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 25vw)"
|
||||
className="w-full h-full group-hover:scale-105 transition-transform duration-500"
|
||||
imgClassName="object-contain max-h-[170px] mx-auto"
|
||||
/>
|
||||
|
||||
@@ -184,6 +184,7 @@ export default function PodcastInlinePlayer({ podcast }: PodcastInlinePlayerProp
|
||||
<audio
|
||||
ref={audioRef}
|
||||
src={podcast.audioUrl}
|
||||
preload="none"
|
||||
onPlay={() => setIsPlaying(true)}
|
||||
onPause={() => setIsPlaying(false)}
|
||||
onTimeUpdate={() => {
|
||||
|
||||
@@ -65,12 +65,14 @@ const useCalculatorStore = create<CalculatorState>((set) => ({
|
||||
setWeight: (weight) => set({ weight }),
|
||||
}));
|
||||
|
||||
import dynamic from 'next/dynamic';
|
||||
import Tooltip from "./Tooltip";
|
||||
import SafeImage from "./SafeImage";
|
||||
import ProductReviews from "./ProductReviews";
|
||||
import VideoModalPlayer from "./VideoModalPlayer";
|
||||
import PodcastInlinePlayer from "./PodcastInlinePlayer";
|
||||
|
||||
const VideoModalPlayer = dynamic(() => import("./VideoModalPlayer"), { ssr: false });
|
||||
const ProductReviews = dynamic(() => import("./ProductReviews"), { ssr: false });
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
@@ -293,6 +295,8 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
<SafeImage
|
||||
src={activeImage || product.image}
|
||||
alt={product.name}
|
||||
priority={true}
|
||||
sizes="(max-width: 768px) 100vw, 400px"
|
||||
className="w-full h-full"
|
||||
imgClassName="max-h-[240px] sm:max-h-[300px] w-auto object-contain drop-shadow-2xl group-hover:scale-105 transition-transform duration-700 mx-auto my-auto"
|
||||
/>
|
||||
|
||||
@@ -10,6 +10,11 @@ interface SafeImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>,
|
||||
className?: string;
|
||||
imgClassName?: string;
|
||||
fallbackText?: string;
|
||||
priority?: boolean;
|
||||
sizes?: string;
|
||||
quality?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
export default function SafeImage({
|
||||
@@ -17,10 +22,15 @@ export default function SafeImage({
|
||||
alt = "تصویر مکمل کنینا",
|
||||
className,
|
||||
imgClassName,
|
||||
fallbackText = "در حال بروزرسانی تصویر..."
|
||||
fallbackText = "در حال بروزرسانی تصویر...",
|
||||
priority = false,
|
||||
sizes = "(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 400px",
|
||||
quality = 85,
|
||||
width = 500,
|
||||
height = 500,
|
||||
}: SafeImageProps) {
|
||||
const [error, setError] = React.useState(false);
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
const [loading, setLoading] = React.useState(!priority);
|
||||
|
||||
// Check if external domain is in allowed remote patterns or relative path
|
||||
const isExternal = typeof src === 'string' && (src.startsWith('http://') || src.startsWith('https://'));
|
||||
@@ -43,7 +53,7 @@ export default function SafeImage({
|
||||
if (!src || error) {
|
||||
return (
|
||||
<div className={cn(
|
||||
"flex flex-col items-center justify-center bg-medical-gray-50/90 border border-medical-gray-100 p-2 text-center w-full h-full rounded-2xl relative overflow-hidden select-none",
|
||||
"flex flex-col items-center justify-center bg-medical-gray-50/90 border border-medical-gray-100 p-2 text-center w-full h-full rounded-2xl relative overflow-hidden select-none aspect-square",
|
||||
className
|
||||
)}>
|
||||
<Image
|
||||
@@ -63,7 +73,7 @@ export default function SafeImage({
|
||||
|
||||
return (
|
||||
<div className={cn("relative overflow-hidden group flex items-center justify-center", className)}>
|
||||
{loading && (
|
||||
{loading && !priority && (
|
||||
<div className="absolute inset-0 bg-medical-gray-50 animate-pulse flex items-center justify-center z-10">
|
||||
<Sparkles className="w-6 h-6 text-canina-blue/20" />
|
||||
</div>
|
||||
@@ -71,14 +81,17 @@ export default function SafeImage({
|
||||
<Image
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={500}
|
||||
height={500}
|
||||
loading="lazy"
|
||||
width={width}
|
||||
height={height}
|
||||
priority={priority}
|
||||
loading={priority ? undefined : "lazy"}
|
||||
sizes={sizes}
|
||||
quality={quality}
|
||||
unoptimized={isBlobOrData || !isAllowedHost}
|
||||
className={cn(
|
||||
"transition-all duration-700 w-full h-full",
|
||||
"transition-all duration-500 w-full h-full object-contain",
|
||||
imgClassName,
|
||||
loading ? "opacity-0 scale-110" : "opacity-100 scale-100"
|
||||
loading && !priority ? "opacity-0 scale-105" : "opacity-100 scale-100"
|
||||
)}
|
||||
onLoad={() => setLoading(false)}
|
||||
onError={() => setError(true)}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import localFont from 'next/font/local';
|
||||
|
||||
export const vazirmatn = localFont({
|
||||
src: [
|
||||
{
|
||||
path: '../public/fonts/vazirmatn-v33.003/fonts/webfonts/Vazirmatn[wght].woff2',
|
||||
style: 'normal',
|
||||
},
|
||||
],
|
||||
variable: '--font-vazir',
|
||||
display: 'swap',
|
||||
fallback: ['system-ui', '-apple-system', 'Segoe UI', 'Roboto', 'Arial', 'sans-serif'],
|
||||
preload: true,
|
||||
});
|
||||
|
||||
export const lalezar = localFont({
|
||||
src: [
|
||||
{
|
||||
path: '../public/fonts/Lalezar-Font-fontyab.com_/Lalezar-Font/TTF/Lalezar-Regular.ttf',
|
||||
weight: '400',
|
||||
style: 'normal',
|
||||
},
|
||||
],
|
||||
variable: '--font-lalezar',
|
||||
display: 'swap',
|
||||
fallback: ['cursive', 'sans-serif'],
|
||||
preload: false,
|
||||
});
|
||||
@@ -232,6 +232,17 @@ export class ProductService {
|
||||
};
|
||||
}
|
||||
|
||||
private async serverFetch(endpoint: string, tags: string[] = ['products'], revalidate = 3600) {
|
||||
const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api';
|
||||
const apiBase = apiUrl.endsWith('/api') ? apiUrl : `${apiUrl.replace(/\/$/, '')}/api`;
|
||||
const cleanEndpoint = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
||||
const res = await fetch(`${apiBase}${cleanEndpoint}`, {
|
||||
next: { tags, revalidate },
|
||||
});
|
||||
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
public async getProducts(filters?: {
|
||||
category?: string;
|
||||
petType?: PetType | "all";
|
||||
@@ -253,6 +264,13 @@ export class ProductService {
|
||||
params.append('limit', String(filters?.limit || 12));
|
||||
|
||||
try {
|
||||
if (typeof window === 'undefined') {
|
||||
const json = await this.serverFetch(`/products?${params.toString()}`, ['products'], 3600);
|
||||
return {
|
||||
data: json.data.map((item: Record<string, unknown>) => this.mapBackendToFrontend(item)),
|
||||
meta: json.meta,
|
||||
};
|
||||
}
|
||||
const response = await api.get(`/products?${params.toString()}`);
|
||||
return {
|
||||
data: response.data.data.map((item: Record<string, unknown>) => this.mapBackendToFrontend(item)),
|
||||
@@ -266,6 +284,10 @@ export class ProductService {
|
||||
|
||||
public async getProductById(id: string): Promise<Product | null> {
|
||||
try {
|
||||
if (typeof window === 'undefined') {
|
||||
const data = await this.serverFetch(`/products/${id}`, ['products'], 3600);
|
||||
return this.mapBackendToFrontend(data);
|
||||
}
|
||||
const response = await api.get(`/products/${id}`);
|
||||
return this.mapBackendToFrontend(response.data);
|
||||
} catch (error) {
|
||||
@@ -276,6 +298,10 @@ export class ProductService {
|
||||
|
||||
public async getProductBySlug(slug: string): Promise<Product | null> {
|
||||
try {
|
||||
if (typeof window === 'undefined') {
|
||||
const data = await this.serverFetch(`/products/${encodeURIComponent(slug)}`, ['products', `product-${slug}`], 3600);
|
||||
return this.mapBackendToFrontend(data);
|
||||
}
|
||||
const response = await api.get(`/products/${slug}`);
|
||||
return this.mapBackendToFrontend(response.data);
|
||||
} catch (error) {
|
||||
|
||||
@@ -12,50 +12,62 @@ const securityHeaders = [
|
||||
const nextConfig: NextConfig = {
|
||||
images: {
|
||||
formats: ['image/avif', 'image/webp'],
|
||||
minimumCacheTTL: 31536000,
|
||||
remotePatterns: [
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'canina.ir',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'api.canina.ir',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'stage.canina.ir',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'stageapi.canina.ir',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'apicanina.parsaaghayi.ir',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'canina.de',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'www.canina.de',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'images.unsplash.com',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'plus.unsplash.com',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'http',
|
||||
hostname: 'localhost',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'http',
|
||||
hostname: '127.0.0.1',
|
||||
pathname: '/**',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -68,12 +80,12 @@ const nextConfig: NextConfig = {
|
||||
];
|
||||
},
|
||||
async rewrites() {
|
||||
// Only proxy /api in development; in production nginx handles it
|
||||
// Only proxy /api in development; exclude local Next.js route handlers such as /api/revalidate
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return [
|
||||
{
|
||||
source: '/api/:path*',
|
||||
destination: 'http://localhost:4001/api/:path*',
|
||||
source: '/api/((?!revalidate).*)',
|
||||
destination: 'http://localhost:4001/api/$1',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user