Struggling to integrate Fauna dB with nextjs using Apollo, I keep facing roadblocks. I'm not sure if I made a mistake or if there's something else at play, but I am determined to find a solution. The latest error message I encountered was:
POST http://localhost:3000/graphql 404
Below is the snippet of my Apollo client script:
import {
ApolloClient,
InMemoryCache,
createHttpLink,
} from '@apollo/client';
import { setContext } from '@apollo/client/link/context';
const httpLink = createHttpLink({
uri: process.env.FAUNADB_GRAPHQL_URL,
});
const authLink = setContext((_, { headers }) => {
const faunaKey = process.env.FAUNA_ADMIN_KEY;
return {
headers: {
...headers,
authorization: `Bearer ${faunaKey}`,
}
}
});
export const client = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(),
});
Any assistance would be greatly appreciated.
I've attempted to switch to different approaches, but without success. Furthermore, tutorials I have come across seem outdated (e.g., The with-fauna nextjs example doesn't work for me).