diff --git a/frontend/application/app/blog/[slug]/page.tsx b/frontend/application/app/blog/[slug]/page.tsx index 6053137c..33fa4ff0 100644 --- a/frontend/application/app/blog/[slug]/page.tsx +++ b/frontend/application/app/blog/[slug]/page.tsx @@ -81,6 +81,13 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str const ogTitle = blog.ogTitle || title; const ogDesc = blog.ogDescription || description; + const isStaging = + process.env.NEXT_PUBLIC_APP_ENV === 'staging' || + process.env.NODE_ENV !== 'production' || + siteUrl.includes('stage') || + siteUrl.includes('test') || + siteUrl.includes('dev'); + const authorName = blog.author ? `${blog.author.firstName || ''} ${blog.author.lastName || ''}`.trim() || 'نویسنده کنینا' : 'نویسنده و پژوهشگر کنینا'; @@ -101,17 +108,28 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str alternates: { canonical: canonicalUrl, }, - robots: { - index: !blog.noIndex, - follow: !blog.noFollow, - googleBot: { - index: !blog.noIndex, - follow: !blog.noFollow, - 'max-image-preview': 'large', - 'max-snippet': -1, - 'max-video-preview': -1, - }, - }, + robots: isStaging + ? { + index: false, + follow: false, + nocache: true, + googleBot: { + index: false, + follow: false, + noimageindex: true, + }, + } + : { + index: !blog.noIndex, + follow: !blog.noFollow, + googleBot: { + index: !blog.noIndex, + follow: !blog.noFollow, + 'max-image-preview': 'large', + 'max-snippet': -1, + 'max-video-preview': -1, + }, + }, openGraph: { title: ogTitle, description: ogDesc, diff --git a/frontend/application/app/shop/[slug]/page.tsx b/frontend/application/app/shop/[slug]/page.tsx index 3cf4d1f1..7e0b9cc8 100644 --- a/frontend/application/app/shop/[slug]/page.tsx +++ b/frontend/application/app/shop/[slug]/page.tsx @@ -49,6 +49,13 @@ export async function generateMetadata( const primaryImage = product.ogImage || product.image || config.ogImageUrl; const imageAlt = product.featuredImageAlt || nameFa; + const isStaging = + process.env.NEXT_PUBLIC_APP_ENV === 'staging' || + process.env.NODE_ENV !== 'production' || + siteUrl.includes('stage') || + siteUrl.includes('test') || + siteUrl.includes('dev'); + const galleryImages = [ { url: primaryImage, @@ -70,17 +77,28 @@ export async function generateMetadata( title, description, keywords, - robots: { - index: !product.noIndex, - follow: !product.noFollow, - googleBot: { - index: !product.noIndex, - follow: !product.noFollow, - 'max-video-preview': -1, - 'max-image-preview': 'large', - 'max-snippet': -1, - }, - }, + robots: isStaging + ? { + index: false, + follow: false, + nocache: true, + googleBot: { + index: false, + follow: false, + noimageindex: true, + }, + } + : { + index: !product.noIndex, + follow: !product.noFollow, + googleBot: { + index: !product.noIndex, + follow: !product.noFollow, + 'max-video-preview': -1, + 'max-image-preview': 'large', + 'max-snippet': -1, + }, + }, openGraph: { title: ogTitle, description, diff --git a/nginx.conf b/nginx.conf index b424840e..c8d98c34 100644 --- a/nginx.conf +++ b/nginx.conf @@ -9,6 +9,16 @@ server { add_header X-Content-Type-Options "nosniff" always; add_header Referrer-Policy "no-referrer-when-downgrade" always; + # Force robots.txt block for staging domains + location = /robots.txt { + if ($host ~* 'stage') { + return 200 "User-agent: *\nDisallow: /\n"; + } + proxy_pass http://127.0.0.1:3000; + proxy_http_version 1.1; + proxy_set_header Host $host; + } + # Main Application (Next.js) location / { proxy_pass http://127.0.0.1:3000;