Skip to content

Commit

Permalink
fix /graphql endpoints cors issue
Browse files Browse the repository at this point in the history
  • Loading branch information
coolchock committed Nov 18, 2024
1 parent 98bd646 commit 34d435c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ const initializeApp = async () => {
app.use(express.urlencoded({limit: '50mb', extended: true}));
app.use(
cors({
origin: getWebsiteDomain(),
allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],
origin: [getWebsiteDomain()],
allowedHeaders: [
'content-type',
...supertokens.getAllCORSHeaders(),
'seed-group',
],
methods: ['GET', 'PUT', 'POST', 'DELETE'],
credentials: true,
})
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/components/ui/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,14 @@ const Home = () => {
async (endpointUrl, requestOptions) => {
console.log('Fetching with custom fetcher');

const result = await fetch(endpointUrl, requestOptions);
const result = await fetch(endpointUrl, {
method: 'POST',
headers: {
'seed-group': requestOptions.headers['seed-group'],
'Content-Type': 'application/json',
},
body: requestOptions.body,
});
const responseBody = await result.json();
const requestBody = JSON.parse(requestOptions.body?.toString()!);

Expand Down

0 comments on commit 34d435c

Please sign in to comment.