Skip to content

Commit

Permalink
Pre-emptive client side partial fix for cors error on data.pro.hasura.io
Browse files Browse the repository at this point in the history
  • Loading branch information
seanparkross committed Feb 3, 2025
1 parent 3f98cdd commit 5bf1380
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/theme/DocRoot/Layout/FetchUser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ export default async function fetchUser() {
const url = 'https://data.pro.hasura.io/v1/graphql';

const headers = {
Accept: '*/*',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.9,es-US;q=0.8,es;q=0.7',
'Content-Type': 'application/json',
'Hasura-Client-Name': 'hasura-docs',
Origin: 'https://hasura.io/docs/3.0',
Referer: 'https://hasura.io/docs/3.0',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'Origin': 'https://hasura.io',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
};

const body = {
Expand All @@ -27,9 +27,15 @@ export default async function fetchUser() {
const response = await fetch(url, {
method: 'POST',
headers: headers,
credentials: 'include',
mode: 'cors',
body: JSON.stringify(body),
});

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

const data = await response.json();
console.log(data);
return data;
Expand Down

0 comments on commit 5bf1380

Please sign in to comment.