From 8823edc8b393790834529d2a203de1d23fccaa51 Mon Sep 17 00:00:00 2001 From: Iliyan Angelov Date: Tue, 25 Nov 2025 11:16:05 +0200 Subject: [PATCH] updates --- frontEnd/app/services/[slug]/page.tsx | 26 +++++++++++++------------- nginx-gnxsoft.conf | 16 +++++++++++++--- start-services.sh | 13 +++++++++++++ 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/frontEnd/app/services/[slug]/page.tsx b/frontEnd/app/services/[slug]/page.tsx index 5b5802db..5a4ca70c 100644 --- a/frontEnd/app/services/[slug]/page.tsx +++ b/frontEnd/app/services/[slug]/page.tsx @@ -12,7 +12,7 @@ import ServicesInitAnimations from "@/components/pages/services/ServicesInitAnim import { Service } from "@/lib/api/serviceService"; import { generateServiceMetadata } from "@/lib/seo/metadata"; import { ServiceSchema, BreadcrumbSchema } from "@/components/shared/seo/StructuredData"; -import { API_CONFIG } from "@/lib/config/api"; +import { API_CONFIG, getApiHeaders } from "@/lib/config/api"; interface ServicePageProps { params: Promise<{ @@ -24,13 +24,13 @@ interface ServicePageProps { // This pre-generates known pages, but new pages can still be generated on-demand export async function generateStaticParams() { try { + // Use internal API URL for server-side requests + const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:1086'; const response = await fetch( - `${API_CONFIG.BASE_URL}/api/services/`, + `${apiUrl}/api/services/`, { method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, + headers: getApiHeaders(), next: { revalidate: 60 }, // Revalidate every minute for faster image updates } ); @@ -57,13 +57,13 @@ export async function generateMetadata({ params }: ServicePageProps) { const { slug } = await params; try { + // Use internal API URL for server-side requests + const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:1086'; const response = await fetch( - `${API_CONFIG.BASE_URL}/api/services/${slug}/`, + `${apiUrl}/api/services/${slug}/`, { method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, + headers: getApiHeaders(), next: { revalidate: 60 }, // Revalidate every minute for faster image updates } ); @@ -87,13 +87,13 @@ const ServicePage = async ({ params }: ServicePageProps) => { const { slug } = await params; try { + // Use internal API URL for server-side requests + const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:1086'; const response = await fetch( - `${API_CONFIG.BASE_URL}/api/services/${slug}/`, + `${apiUrl}/api/services/${slug}/`, { method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, + headers: getApiHeaders(), next: { revalidate: 60 }, // Revalidate every minute for faster image updates } ); diff --git a/nginx-gnxsoft.conf b/nginx-gnxsoft.conf index f4e62095..f2689436 100644 --- a/nginx-gnxsoft.conf +++ b/nginx-gnxsoft.conf @@ -200,12 +200,22 @@ server { } } - # Frontend public images - location /images/ { - alias /var/www/GNX-WEB/frontEnd/public/images/; + # Frontend public images - must come before root location + location ~ ^/images/(.*)$ { + alias /var/www/GNX-WEB/frontEnd/public/images/$1; expires 30d; add_header Cache-Control "public, immutable"; access_log off; + + # Ensure proper MIME types + types { + image/png png; + image/jpeg jpg jpeg; + image/gif gif; + image/svg+xml svg; + image/webp webp; + } + default_type application/octet-stream; } # Root location - Frontend (Next.js) - MUST be last diff --git a/start-services.sh b/start-services.sh index 6554cb1c..e140b5b7 100755 --- a/start-services.sh +++ b/start-services.sh @@ -221,6 +221,19 @@ if grep -q '"output":\s*"standalone"' next.config.js 2>/dev/null || grep -q "out NODE_ENV=production PORT=$FRONTEND_PORT npm run build fi + # Ensure public folder is copied to standalone directory + if [ ! -d ".next/standalone/public" ]; then + echo -e "${BLUE}Copying public folder to standalone directory...${NC}" + cp -r public .next/standalone/ + fi + + # Ensure static folder symlink exists for image optimization + if [ ! -L ".next/standalone/.next/static" ] && [ ! -d ".next/standalone/.next/static" ]; then + echo -e "${BLUE}Creating symlink for static files...${NC}" + mkdir -p .next/standalone/.next + ln -s ../../static .next/standalone/.next/static + fi + # Start standalone server with PM2 PORT=$FRONTEND_PORT NODE_ENV=production pm2 start node \ --name "gnxsoft-frontend" \