Обновлен конфиг middleware для применения правил маршрутизации. Теперь он исключает запросы к API, статическим файлам и метаданным, что улучшает обработку запросов и повышает гибкость работы с приложением.

This commit is contained in:
Bivekich
2025-07-06 20:23:50 +03:00
parent 2841996b31
commit 667a581251
3 changed files with 54 additions and 1 deletions

25
src/app/robots.ts Normal file
View File

@ -0,0 +1,25 @@
import type { MetadataRoute } from 'next'
export default function robots(): MetadataRoute.Robots {
return {
rules: [
{
userAgent: '*',
disallow: '/',
},
{
userAgent: 'Googlebot',
disallow: '/',
},
{
userAgent: 'Bingbot',
disallow: '/',
},
{
userAgent: 'Yandex',
disallow: '/',
},
],
sitemap: 'https://admin.protekauto.ru/sitemap.xml',
}
}

18
src/app/sitemap.ts Normal file
View File

@ -0,0 +1,18 @@
import type { MetadataRoute } from 'next'
export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: 'https://admin.protekauto.ru',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.1,
},
{
url: 'https://admin.protekauto.ru/login',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.1,
},
]
}

View File

@ -24,5 +24,15 @@ export function middleware(request: NextRequest) {
// Указываем, для каких путей применять middleware
export const config = {
matcher: ['/api/:path*'],
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico, sitemap.xml, robots.txt (metadata files)
*/
'/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)',
'/api/:path*'
],
}