这是我的代码,我想我完全遵循 next-urql 指令,
import { withUrqlClient } from "next-urql"
import { dedupExchange,cacheExchange,fetchExchange,ssrExchange } from "urql";
// import { cacheExchange } from "@urql/exchange-graphcache";
import { Navbar } from "../components/Navbar"
import { useTodosQuery } from "../generated/graphql";
import { createUrqlClient } from "../utils/createUrqlClient"
const Index = () => {
const [{data}] = useTodosQuery();
return(
<>
<Navbar/>
<div>Hello world</div>
<br></br>
{!data ? (<div>Loading...</div>): data.todos.map((todo) => <div key={todo.id}>{todo.title}</div>)}
</>
)
};
export default withUrqlClient( (ssrExchange:any)=>({
url:'https://localhost:4000/graphql',
//for the cookie to workz
fetchOptions:{
credentials:"include"
},
//for cache update
exchanges: [dedupExchange,cacheExchange, ssrExchange, fetchExchange]
}))(Index);
所以事情就是这样,当我不设置 {ssr:true} 时它工作正常,但为了使用服务器端渲染,我必须激活它,之后,我的网站不会向我的网站发送任何请求服务器,所以它无法工作,我想知道这是为什么