vendure-auth-token in next js

vendure-auth-token in next js


0

As I am using vendure graphql in my next js project and I am using apolloClient for query and mutation , I am facing an problem while loging in

My client code

import { HttpLink } from "@apollo/client";

import {
  NextSSRInMemoryCache,
  NextSSRApolloClient,
} from "@apollo/experimental-nextjs-app-support/ssr";
import { registerApolloClient } from "@apollo/experimental-nextjs-app-support/rsc";

const { BACKEND_URL } = process.env;

export const { getClient } = registerApolloClient(() => {
  return new NextSSRApolloClient({
    cache: new NextSSRInMemoryCache(),
    link: new HttpLink({
      uri: BACKEND_URL as string,
      credentials: "include",
    }),
  });
});

My login code

const apolloClient = getClient();

export const login = async ({
  username,
  password,
  rememberMe,
}: MutationLoginArgs) => {
  const response = await apolloClient.mutate<LoginMutation>({
    mutation: Login,
    variables: {
      rememberMe: rememberMe ? true : false,
      username,
      password,
    },
  });
  return response;
};

I am getting vendure-auth-token in graphql playground network >> response >> headers.

How to get this vendure-auth-token in code for further authorize query and mutation


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *