feat(application): implement Phase 2 SEO metadata, Next.js image optimization, and HTTP security headers
Deploy Canina / deploy (push) Failing after 28s

This commit is contained in:
parsa committed 2026-08-06 23:02:07 +03:30
1 parent 9c334c39ae
commit 57596f5aaf
4 files changed
+69 -16

No files matched your search

+16 -5
View File
@@ -2,8 +2,10 @@ import type { Metadata } from 'next';
import './globals.css';
import ClientLayout from './ClientLayout';
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://canina-iran.com';
export const metadata: Metadata = {
metadataBase: new URL(process.env.NEXT_PUBLIC_SITE_URL || 'https://canina-iran.com'),
metadataBase: new URL(siteUrl),
title: {
template: '%s | کانینا ایران',
default: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی',
@@ -14,7 +16,7 @@ export const metadata: Metadata = {
creator: 'Canina Iran',
publisher: 'Canina Iran',
alternates: {
canonical: './',
canonical: '/',
},
formatDetection: {
email: false,
@@ -24,15 +26,24 @@ export const metadata: Metadata = {
openGraph: {
title: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی',
description: 'واردکننده انحصاری مکمل‌های درمانی با گرید دارویی اختصاصی از آلمان',
url: 'https://canina-iran.com',
url: siteUrl,
siteName: 'کانینا ایران',
locale: 'fa_IR',
type: 'website',
images: [
{
url: '/assets/images/regenerated_image_1779109861747.png',
width: 1200,
height: 630,
alt: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی',
},
],
},
twitter: {
card: 'summary_large_image',
title: 'کانینا ایران',
description: 'مکمل‌های درمانی حیوانات خانگی کانینا',
title: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی',
description: 'مکمل‌های درمانی حیوانات خانگی کانینا با پروانه رسمی دامپزشکی',
images: ['/assets/images/regenerated_image_1779109861747.png'],
},
robots: {
index: true,
+6
View File
@@ -22,6 +22,12 @@ export const metadata: Metadata = {
alt: "کانینا ایران - مکمل‌های درمانی حیوانات خانگی",
}
]
},
twitter: {
card: "summary_large_image",
title: "کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی",
description: "تدارک هوشمندانه سلامت برای همراهان وفادار شما.",
images: ["/assets/images/regenerated_image_1779109861747.png"],
}
};
+19 -7
View File
@@ -25,9 +25,13 @@ const api = axios.create({
// Interceptor to add auth token in request headers
api.interceptors.request.use(
(config) => {
let token = null;
if (typeof window !== 'undefined') {
token = localStorage.getItem('accessToken');
let token: string | null = null;
if (typeof window !== 'undefined' && window.localStorage) {
try {
token = localStorage.getItem('accessToken');
} catch (e) {
console.warn('Storage access restricted:', e);
}
}
if (token && config.headers) {
config.headers.Authorization = `Bearer ${token}`;
@@ -48,8 +52,12 @@ api.interceptors.response.use(
// Handle 401 Unauthorized globally - trigger Auth Modal
if (status === 401) {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
if (window.localStorage) {
try {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
} catch {}
}
try {
useUserStore.getState().logout();
useUserStore.getState().setAuthModalOpen(true);
@@ -57,8 +65,12 @@ api.interceptors.response.use(
// Ignore if store not ready
}
} else if (status === 403) {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
if (window.localStorage) {
try {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
} catch {}
}
try {
useUserStore.getState().logout();
} catch {
+28 -4
View File
@@ -1,19 +1,44 @@
import type { NextConfig } from "next";
const securityHeaders = [
{ key: 'X-DNS-Prefetch-Control', value: 'on' },
{ key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' },
{ key: 'X-Frame-Options', value: 'SAMEORIGIN' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'origin-when-cross-origin' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
];
const nextConfig: NextConfig = {
images: {
unoptimized: true,
formats: ['image/avif', 'image/webp'],
remotePatterns: [
{
protocol: 'https',
hostname: '**',
hostname: 'canina-iran.com',
},
{
protocol: 'https',
hostname: 'apicanina.parsaaghayi.ir',
},
{
protocol: 'https',
hostname: 'canina.de',
},
{
protocol: 'http',
hostname: '**',
hostname: 'localhost',
},
],
},
async headers() {
return [
{
source: '/:path*',
headers: securityHeaders,
},
];
},
async rewrites() {
// Only proxy /api in development; in production nginx handles it
if (process.env.NODE_ENV === 'development') {
@@ -29,4 +54,3 @@ const nextConfig: NextConfig = {
};
export default nextConfig;