I have a Next.js app and using apollo-client for GraphCMS.
Once I have set environment variables for URI and token on ApolloClient object, GraphQL query does not work and return. Actually, I can get data from GraphCMS. The problem is only for mutations.
Here is the .env file:
GRAPHCMS_ENDPOINT=https://api-some-thing.graphcms.com/v2/sd3s
GRAPHCMS_TOKEN=tsd89asd24jnNM
And here is apollo-client.js:
import { ApolloClient, InMemoryCache } from "@apollo/client";
const client = new ApolloClient({
uri: process.env.GRAPHCMS_ENDPOINT,
cache: new InMemoryCache(),
headers: {
"Authorization": `Bearer ${process.env.GRAPHCMS_TOKEN}`
}
});
export default client;
If I set URI and token as string I mean not using process.env, everything works fine.
What am I missing?