Skip to content

Commit

Permalink
fix: await header-based methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarendorff committed Oct 5, 2024
1 parent ff96c08 commit 8c7b921
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/web/src/context/user/logout-server-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const deleteCookie = (cookies: ReadonlyRequestCookies, name: string) => {
export const logout = async () => {
await graphqlWithHeaders((sdk) => sdk.Logout({}));

const cks = cookies();
const cks = await cookies();
deleteCookie(cks, 'koa.sess');
deleteCookie(cks, 'koa.sess.sig');
};
6 changes: 3 additions & 3 deletions packages/web/src/lib/graphql/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {headers} from 'next/headers';
import {notFound} from 'next/navigation';
import {getSdk, type Sdk} from '../../__generated__/graphql';

export const getGraphqlClient = () => {
const requestHeaders = headers();
export const getGraphqlClient = async () => {
const requestHeaders = await headers();

if (!process.env.SERVER_BACKEND_GRAPHQL_URL) {
if (process.env.NODE_ENV !== 'production') {
Expand Down Expand Up @@ -42,7 +42,7 @@ export const getGraphqlClient = () => {
export const graphqlWithHeaders = async <T>(
cb: (sdk: Sdk) => Promise<T>,
): Promise<T> => {
const client = getGraphqlClient();
const client = await getGraphqlClient();

return await cb(client);
};
Expand Down

0 comments on commit 8c7b921

Please sign in to comment.