-
Notifications
You must be signed in to change notification settings - Fork 0
Generate env specific robots.txt #507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||||||||||||||||
| import { MetadataRoute } from "next"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default function robots(): MetadataRoute.Robots { | ||||||||||||||||||||||
| if (process.env.APP_ENV === "production") { | ||||||||||||||||||||||
| return { | ||||||||||||||||||||||
| rules: [ | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| userAgent: "Bytedance", | ||||||||||||||||||||||
| disallow: "/", | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| userAgent: "Bytespider", | ||||||||||||||||||||||
| disallow: "/", | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| userAgent: "GPTBot", | ||||||||||||||||||||||
| disallow: "/", | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| ], | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // No bot access for non-prod environments | ||||||||||||||||||||||
| return { | ||||||||||||||||||||||
| rules: { | ||||||||||||||||||||||
| userAgent: "*", | ||||||||||||||||||||||
| disallow: "/", | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
|
Comment on lines
+25
to
+28
|
||||||||||||||||||||||
| rules: { | |
| userAgent: "*", | |
| disallow: "/", | |
| }, | |
| rules: [ | |
| { | |
| userAgent: "*", | |
| disallow: "/", | |
| }, | |
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Robots type can be an array or single object, gonna ignore this
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The production rules block specific bots but don't specify behavior for other crawlers. This means bots like Googlebot will have unrestricted access by default. Consider adding an explicit rule for '*' user agent with 'allow: /' to make the intent clear, or add 'allow' rules for the blocked bots if they should only be blocked from specific paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gonna ignore this to maintain the exact existing robots.txt