Skip to content

Commit

Permalink
Allow any CORS on api/v1/plugins/ and api/v1/plugins/metas/
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Nov 25, 2024
1 parent b7e7840 commit 744c4a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chris_backend/plugins/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

class PluginsConfig(AppConfig):
name = 'plugins'

def ready(self):
from plugins import handlers

12 changes: 12 additions & 0 deletions chris_backend/plugins/handlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from corsheaders.signals import check_request_enabled
import re

_ALLOWED = re.compile(r'/api/v1/plugins/(metas/)?(search/)?(\d+/)?')


def cors_allow_api_to_everyone(sender, request, **kwargs):
return _ALLOWED.fullmatch(request.path)


check_request_enabled.connect(cors_allow_api_to_everyone)

0 comments on commit 744c4a3

Please sign in to comment.