Skip to content

Saleor Core: the high performance, composable, headless commerce API.

fix: plugins can now query the API without content-security-policy re… (#8665)

LeOndaz7468c40f2e84
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.py
index 0c1ed83f25..660738e203 100644
--- a/saleor/graphql/views.py
+++ b/saleor/graphql/views.py
@@ -120,7 +120,10 @@ class GraphQLView(View):
return render(
request,
"graphql/playground.html",
- {"api_url": request.build_absolute_uri(str(API_PATH))},
+ {
+ "api_url": request.build_absolute_uri(str(API_PATH)),
+ "plugins_url": request.build_absolute_uri("/plugins/"),
+ },
)
def _handle_query(self, request: HttpRequest) -> JsonResponse:
diff --git a/templates/graphql/playground.html b/templates/graphql/playground.html
index 25c530bba3..8c9560a4d4 100644
--- a/templates/graphql/playground.html
+++ b/templates/graphql/playground.html
@@ -7,7 +7,7 @@
<link rel="stylesheet" crossorigin="anonymous" integrity="sha256-dKnNLEFwKSVFpkpjRWe+o/jQDM6n/JsvQ0J3l5Dk3fc" href="https://cdn.jsdelivr.net/npm/[email protected]/build/static/css/index.css" />
<link rel="shortcut icon" href="https://cdn.jsdelivr.net/npm/[email protected]/build/favicon.png" />
<script crossorigin="anonymous" integrity="sha256-24AcA5M3t+KN6ZRQvfqBG51OyLciyk0UJwVBAX94SZI=" src="https://cdn.jsdelivr.net/npm/[email protected]/build/static/js/middleware.js"></script>
- <meta http-equiv="content-security-policy" content="default-src 'none'; connect-src {{ api_url }}; script-src 'sha256-24AcA5M3t+KN6ZRQvfqBG51OyLciyk0UJwVBAX94SZI=' 'sha256-jpQ7CLb9c8nrwEY+pDfFNOgGpKzrNTRsWVv4yB8QVnQ='; style-src https://cdn.jsdelivr.net/npm/[email protected]/build/static/css/index.css 'sha256-jkwxzyKPdPQHgIYu9x7it0jbIOtzMGr9iFmRtSaiwX4='; img-src data: https://cdn.jsdelivr.net/npm/[email protected]/build/static/media/logo.8c98d067.png https://cdn.jsdelivr.net/npm/[email protected]/build/favicon.png">
+ <meta http-equiv="content-security-policy" content="default-src 'none'; connect-src {{ api_url }} {{ plugins_url }}; script-src 'sha256-24AcA5M3t+KN6ZRQvfqBG51OyLciyk0UJwVBAX94SZI=' 'sha256-jpQ7CLb9c8nrwEY+pDfFNOgGpKzrNTRsWVv4yB8QVnQ='; style-src https://cdn.jsdelivr.net/npm/[email protected]/build/static/css/index.css 'sha256-jkwxzyKPdPQHgIYu9x7it0jbIOtzMGr9iFmRtSaiwX4='; img-src data: https://cdn.jsdelivr.net/npm/[email protected]/build/static/media/logo.8c98d067.png https://cdn.jsdelivr.net/npm/[email protected]/build/favicon.png">
</head>
<body>
<div id="root" data-endpoint="{{ api_url }}" {% if query %}data-query="{{ query }}"{% endif %}>