This commit is contained in:
Iliyan Angelov
2025-11-25 11:16:05 +02:00
parent 4c8b71fe0d
commit 8823edc8b3
3 changed files with 39 additions and 16 deletions

View File

@@ -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
}
);

View File

@@ -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

View File

@@ -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" \