The apollo client configuration seems to be changed a bit now.
import {
ApolloClient,
createHttpLink,
gql,
InMemoryCache,
} from "@apollo/client";
import { setContext } from "@apollo/client/link/context";
const API_URL = "YOUR_URL";
const httpLink = createHttpLink({ uri: API_URL });
const authLink = setContext((_, { headers }) => {
const token = localStorage.getItem("access_token");
return {
headers: {
...headers,
"x-access-token": token ? `Bearer ${token}` : "",
},
};
});
export const apolloClient = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(),
});
The apollo client configuration seems to be changed a bit now.
import { ApolloClient, createHttpLink, gql, InMemoryCache, } from "@apollo/client"; import { setContext } from "@apollo/client/link/context"; const API_URL = "YOUR_URL"; const httpLink = createHttpLink({ uri: API_URL }); const authLink = setContext((_, { headers }) => { const token = localStorage.getItem("access_token"); return { headers: { ...headers, "x-access-token": token ? `Bearer ${token}` : "", }, }; }); export const apolloClient = new ApolloClient({ link: authLink.concat(httpLink), cache: new InMemoryCache(), });