Skip to content
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

added robots.txt for API endpoints #3165

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/api/templates/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Block API endpoints
User-agent: *
Disallow: /v1/images/
Disallow: /v1/audio/
Disallow: /v1/auth/

User-agent: GPTBot
Disallow: /
9 changes: 8 additions & 1 deletion api/conf/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.views.generic import RedirectView, TemplateView
from rest_framework.routers import SimpleRouter

from api.views.audio_views import AudioViewSet
Expand All @@ -35,6 +35,13 @@
path("admin/", admin.site.urls),
path("healthcheck/", HealthCheck.as_view(), name="health"),
path("v1/", include(versioned_paths)),
path(
"robots.txt/",
Copy link
Member

@dhruvkb dhruvkb Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there should be a trailing slash for a .txt file. I'm leaning towards no, there shouldn't be one.

Suggested change
"robots.txt/",
"robots.txt",

I'll let the other reviewers chime in on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will keep that in mind

TemplateView.as_view(
template_name="robots.txt",
content_type="text/plain",
),
),
]

if settings.ENVIRONMENT == "local":
Expand Down