From 795b738db070de5e255421b1fffb899b014f3b58 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Wed, 11 Sep 2024 14:44:50 -0400 Subject: [PATCH] Reapply "Remove hardcoded auth details from debugging" This reverts commit 0d086db6cde11d74f446fb8170702899f2f542c1. --- src/components/App.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index b305ab4..81da0a2 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -58,7 +58,7 @@ export function App() { Field( node ) { if ( node.name.value === '__schema' || - node.name.value === '__typename' + node.name.value === '__type' ) { isIntrospectionQuery = true; return visit.BREAK; // Early exit if introspection query is detected @@ -71,22 +71,22 @@ export function App() { const { graphqlEndpoint } = window.WPGRAPHQL_IDE_DATA; - const base64Credentials = btoa( `growth:growth` ); - const headers = { 'Content-Type': 'application/json', - Authorization: `Basic ${ base64Credentials }`, }; + const credentials = isIntrospectionQuery + ? 'include' + : isAuthenticated + ? 'include' + : 'omit'; + + console.log({credentials}); const response = await fetch( graphqlEndpoint, { method: 'POST', headers, body: JSON.stringify( graphQLParams ), - credentials: isIntrospectionQuery - ? 'include' - : isAuthenticated - ? 'include' - : 'omit', + credentials, } ); return response.json();