与 Urql客户端在激活 ssr 时不起作用?



这是我的代码,我认为我完全遵循了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},但为了使用服务器端渲染我必须激活它,之后,我的网站不会发送任何请求到我的服务器,所以它无法工作,我想知道为什么是

我认为这里是错误的:

url:'https://localhost:4000/graphql',

代替"https"使用"http">

最新更新