updates
This commit is contained in:
@@ -12,7 +12,7 @@ import ServicesInitAnimations from "@/components/pages/services/ServicesInitAnim
|
|||||||
import { Service } from "@/lib/api/serviceService";
|
import { Service } from "@/lib/api/serviceService";
|
||||||
import { generateServiceMetadata } from "@/lib/seo/metadata";
|
import { generateServiceMetadata } from "@/lib/seo/metadata";
|
||||||
import { ServiceSchema, BreadcrumbSchema } from "@/components/shared/seo/StructuredData";
|
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 {
|
interface ServicePageProps {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
@@ -24,13 +24,13 @@ interface ServicePageProps {
|
|||||||
// This pre-generates known pages, but new pages can still be generated on-demand
|
// This pre-generates known pages, but new pages can still be generated on-demand
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
try {
|
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(
|
const response = await fetch(
|
||||||
`${API_CONFIG.BASE_URL}/api/services/`,
|
`${apiUrl}/api/services/`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: getApiHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
next: { revalidate: 60 }, // Revalidate every minute for faster image updates
|
next: { revalidate: 60 }, // Revalidate every minute for faster image updates
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -57,13 +57,13 @@ export async function generateMetadata({ params }: ServicePageProps) {
|
|||||||
const { slug } = await params;
|
const { slug } = await params;
|
||||||
|
|
||||||
try {
|
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(
|
const response = await fetch(
|
||||||
`${API_CONFIG.BASE_URL}/api/services/${slug}/`,
|
`${apiUrl}/api/services/${slug}/`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: getApiHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
next: { revalidate: 60 }, // Revalidate every minute for faster image updates
|
next: { revalidate: 60 }, // Revalidate every minute for faster image updates
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -87,13 +87,13 @@ const ServicePage = async ({ params }: ServicePageProps) => {
|
|||||||
const { slug } = await params;
|
const { slug } = await params;
|
||||||
|
|
||||||
try {
|
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(
|
const response = await fetch(
|
||||||
`${API_CONFIG.BASE_URL}/api/services/${slug}/`,
|
`${apiUrl}/api/services/${slug}/`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: getApiHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
next: { revalidate: 60 }, // Revalidate every minute for faster image updates
|
next: { revalidate: 60 }, // Revalidate every minute for faster image updates
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -200,12 +200,22 @@ server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Frontend public images
|
# Frontend public images - must come before root location
|
||||||
location /images/ {
|
location ~ ^/images/(.*)$ {
|
||||||
alias /var/www/GNX-WEB/frontEnd/public/images/;
|
alias /var/www/GNX-WEB/frontEnd/public/images/$1;
|
||||||
expires 30d;
|
expires 30d;
|
||||||
add_header Cache-Control "public, immutable";
|
add_header Cache-Control "public, immutable";
|
||||||
access_log off;
|
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
|
# Root location - Frontend (Next.js) - MUST be last
|
||||||
|
|||||||
@@ -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
|
NODE_ENV=production PORT=$FRONTEND_PORT npm run build
|
||||||
fi
|
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
|
# Start standalone server with PM2
|
||||||
PORT=$FRONTEND_PORT NODE_ENV=production pm2 start node \
|
PORT=$FRONTEND_PORT NODE_ENV=production pm2 start node \
|
||||||
--name "gnxsoft-frontend" \
|
--name "gnxsoft-frontend" \
|
||||||
|
|||||||
Reference in New Issue
Block a user