add DEV_MODE support to metadata generation and robots handling; update .gitignore and docker-compose for environment variables
This commit is contained in:
+4
-1
@@ -27,6 +27,10 @@ yarn-error.log*
|
|||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
.env*.local
|
.env*.local
|
||||||
|
.env
|
||||||
|
|
||||||
|
# Environment files with sensitive data
|
||||||
|
.env.docker.production
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
@@ -36,4 +40,3 @@ yarn-error.log*
|
|||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
.idx/dev.nix
|
.idx/dev.nix
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
.env
|
|
||||||
|
|||||||
@@ -28,6 +28,23 @@ export async function generateMetadata() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add noindex meta tag when DEV_MODE is TRUE
|
||||||
|
if (process.env.DEV_MODE === 'TRUE') {
|
||||||
|
baseMetadata.robots = {
|
||||||
|
index: false,
|
||||||
|
follow: false,
|
||||||
|
nocache: true,
|
||||||
|
googleBot: {
|
||||||
|
index: false,
|
||||||
|
follow: false,
|
||||||
|
noimageindex: true,
|
||||||
|
'max-video-preview': -1,
|
||||||
|
'max-image-preview': 'large',
|
||||||
|
'max-snippet': -1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Add canonical URL only if we're not on the main domain and matchedCity domain is not nobat724.com
|
// Add canonical URL only if we're not on the main domain and matchedCity domain is not nobat724.com
|
||||||
if (canonicalUrl && (!matchedCity || matchedCity.domain !== 'nobat724.com')) {
|
if (canonicalUrl && (!matchedCity || matchedCity.domain !== 'nobat724.com')) {
|
||||||
baseMetadata.alternates = {
|
baseMetadata.alternates = {
|
||||||
|
|||||||
@@ -22,6 +22,17 @@ export default function robots() {
|
|||||||
const domain = getCurrentDomain();
|
const domain = getCurrentDomain();
|
||||||
const baseUrl = getBaseUrl(domain);
|
const baseUrl = getBaseUrl(domain);
|
||||||
|
|
||||||
|
// If DEV_MODE is TRUE, disallow all crawlers
|
||||||
|
if (process.env.DEV_MODE === 'TRUE') {
|
||||||
|
return {
|
||||||
|
rules: {
|
||||||
|
userAgent: '*',
|
||||||
|
disallow: '/',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal behavior when DEV_MODE is FALSE or not set
|
||||||
return {
|
return {
|
||||||
rules: {
|
rules: {
|
||||||
userAgent: '*',
|
userAgent: '*',
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
- NODE_ENV=${NODE_ENV}
|
- NODE_ENV=${NODE_ENV}
|
||||||
|
- DEV_MODE=${DEV_MODE}
|
||||||
- NEXT_TELEMETRY_DISABLED=1
|
- NEXT_TELEMETRY_DISABLED=1
|
||||||
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||||
- NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID}
|
- NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID}
|
||||||
@@ -17,6 +18,7 @@ services:
|
|||||||
- "${APP_PORT}:3000"
|
- "${APP_PORT}:3000"
|
||||||
environment:
|
environment:
|
||||||
- NEXT_TELEMETRY_DISABLED=1
|
- NEXT_TELEMETRY_DISABLED=1
|
||||||
|
- DEV_MODE=${DEV_MODE}
|
||||||
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||||
- NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID}
|
- NEXT_PUBLIC_CLIENT_ID=${NEXT_PUBLIC_CLIENT_ID}
|
||||||
- NEXT_PUBLIC_CLIENT_SECRET=${NEXT_PUBLIC_CLIENT_SECRET}
|
- NEXT_PUBLIC_CLIENT_SECRET=${NEXT_PUBLIC_CLIENT_SECRET}
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ const nextConfig = {
|
|||||||
images: {
|
images: {
|
||||||
domains: ["back-dev.clinic-pro.ir"],
|
domains: ["back-dev.clinic-pro.ir"],
|
||||||
},
|
},
|
||||||
|
env: {
|
||||||
|
// Make DEV_MODE available to the application
|
||||||
|
DEV_MODE: process.env.DEV_MODE,
|
||||||
|
},
|
||||||
|
// Additional configuration for better Docker support
|
||||||
|
trailingSlash: false,
|
||||||
|
compress: true,
|
||||||
|
poweredByHeader: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user