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 file for the API #3148

Closed
wants to merge 2 commits into from
Closed
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: /
Comment on lines +6 to +8
Copy link
Member

Choose a reason for hiding this comment

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

This bit is not necessary because we've already restricted all API endpoints to all bots (* on line 2). But we can keep it, no problems.

8 changes: 8 additions & 0 deletions api/conf/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.views.generic.base import TemplateView
from rest_framework.routers import SimpleRouter

from api.views.audio_views import AudioViewSet
Expand All @@ -35,6 +36,13 @@
path("admin/", admin.site.urls),
path("healthcheck/", HealthCheck.as_view(), name="health"),
path("v1/", include(versioned_paths)),
path(
"robots.txt/",
TemplateView.as_view(
template_name="robots.txt",
content_type="text/plain",
),
),
]

if settings.ENVIRONMENT == "local":
Expand Down
1 change: 1 addition & 0 deletions api/conf/urls/openapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.urls import path
from django.views.generic.base import TemplateView
Copy link
Member

Choose a reason for hiding this comment

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

This import should be removed so that lint check can pass. TemplateView is not used in the file so the linter complains that it should not be imported.


from drf_spectacular.views import (
SpectacularAPIView,
Expand Down