feat: robots.txt app router

This commit is contained in:
DIYgod 2023-05-08 17:48:04 +01:00
parent 3eb0594ac1
commit 778d685cb0
No known key found for this signature in database
4 changed files with 14 additions and 1 deletions

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

@ -0,0 +1,11 @@
import { MetadataRoute } from "next"
export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: "*",
allow: "/",
disallow: ["/dashboard/", "/preview/", "/api/"],
},
}
}

View File

@ -53,7 +53,9 @@ export default async function middleware(req: NextRequest) {
pathname.startsWith("/locales/") ||
pathname.match(/^\/(workbox|worker|fallback)-\w+\.js(\.map)?$/) ||
pathname === "/sw.js" ||
pathname === "/sw.js.map"
pathname === "/sw.js.map" ||
pathname === "/robots.txt" ||
pathname === "/sitemap.xml"
) {
return NextResponse.next()
}