I have created a Next.js app using Wordpress as a CMS and WPGraphQL to fetch data. I have created apollo-client the following way:
uri: process.env.NEXT_PUBLIC_WP_API_URL,
headers: {
'Authorization': process.env.NEXT_PUBLIC_WP_AUTHORIZATION,
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'http://localhost:3000/',
'Access-Control-Allow-Credentials': true,
},
credentials: 'include',
fetchOptions: {
mode: 'no-cors'
}
})
const client = new ApolloClient({
link: httpLink,
cache: new InMemoryCache()
});
I can fetch data using getStaticProps and getServerSideProps with or without token but when trying with useQuery and a token it doesn't work: I get the data logged in the terminal and my Chrome networks shows a CORS issue. Anyone had experienced it before?