diff --git a/components/layout/footer/index.js b/components/layout/footer/index.js index aef4e1e..4d72682 100644 --- a/components/layout/footer/index.js +++ b/components/layout/footer/index.js @@ -27,6 +27,22 @@ const head = [ }, ]; +function buildSocialUrl(name, value) { + if (!value) return null; + if (/^https?:\/\//i.test(value)) return value; + const handle = value.replace(/^@/, "").replace(/^\+/, ""); + switch (name) { + case "instagram": + return `https://instagram.com/${handle}`; + case "telegram": + return `https://t.me/${handle}`; + case "whatsapp": + return `https://wa.me/${handle.replace(/\D/g, "")}`; + default: + return value; + } +} + function Footer({ matchedCity }) { const socialMedias = [ { @@ -114,20 +130,31 @@ function Footer({ matchedCity }) { همراه با ما باشید:

diff --git a/next.config.js b/next.config.js index 263efe7..b918fa2 100644 --- a/next.config.js +++ b/next.config.js @@ -41,13 +41,31 @@ const nextConfig = { // Enable standalone output for Docker output: 'standalone', async headers() { + const isDev = process.env.NODE_ENV !== 'production'; + let apiOrigin = ''; + try { + apiOrigin = new URL(process.env.NEXT_PUBLIC_API_URL).origin; + } catch { + apiOrigin = ''; + } + + const connectSrc = [ + "'self'", + apiOrigin, + 'https://clinic-pro.ir', + 'https://back-dev.clinic-pro.ir', + ...(isDev ? ['ws:', 'wss:'] : []), + ] + .filter(Boolean) + .join(' '); + const csp = [ "default-src 'self'", "img-src 'self' https: data: blob:", "script-src 'self' 'unsafe-inline' 'unsafe-eval'", "style-src 'self' 'unsafe-inline'", "font-src 'self' data:", - "connect-src 'self' https://api.clinic-pro.ir https://back-dev.clinic-pro.ir", + 'connect-src ' + connectSrc, "frame-ancestors 'none'", "object-src 'none'", "base-uri 'self'",