Skip to content

Commit

Permalink
make sure the csrf route has nocache
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomax committed Nov 18, 2021
1 parent 35fb41f commit 8d45dcb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion network-api/networkapi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def get_robots_content():
return 'User-Agent: *\nDisallow: /*/artifacts/thimble\nDisallow: /artifacts/thimble'


def csrf_response(request):
response = render(request, 'api/csrf.html')
response['Cache-Control'] = 'no-cache'
return response


urlpatterns = list(filter(None, [
path('robots.txt', lambda x: HttpResponse(
get_robots_content(),
Expand All @@ -62,7 +68,7 @@ def get_robots_content():
re_path(r'^soc/', include('social_django.urls', namespace='social')),

# CSRF endpoint
re_path(r'^api/csrf/', lambda request: render(request, 'api/csrf.html')),
re_path(r'^api/csrf/', csrf_response),

# network API routes:

Expand Down

0 comments on commit 8d45dcb

Please sign in to comment.