我m trying to build app with next.js ,apollo client at frontend and graphql-yoga and prisma at backend and i have problem with apollo client extension to chrome it cant fetch my date . That
的外观。
Failed to fetch error picture。那是代码:
import withApollo from "next-with-apollo";
import ApolloClient from "apollo-boost";
import { endpoint } from "../config";
function createClient({ headers }) {
return new ApolloClient({
uri: process.env.NODE_ENV === "development" ? endpoint : endpoint,
request: operation => {
operation.setContext({
fetchOptions: {
credentials: "include",
connectToDevTools: true
},
headers
});
}
});
}
export default withApollo(createClient);
我知道那一定是我愚蠢的失态,但我找不到。对于尝试帮助我的每个人,谢谢。
答案 0 :(得分:0)
您尝试在服务器上启用cors吗?
import cors from 'cors'
const app = express();
app.use(cors('*'))
https://www.prisma.io/blog/enabling-cors-for-express-graphql-apollo-server-1ef999bfb38d