小编bla*_*oul的帖子

Git子模块工作流问题

最近我们的Git存储库遇到了很多问题.我们是git子模块的用户,我们的应用程序之间共有4个共享存储库.

例如,存储库"网站"总共有3个子模块.

[submodule "vendor/api"]
    path = vendor/api
    url = git@your.cool.domain.com:api
[submodule "vendor/auth"]
    path = vendor/auth
    url = git@your.cool.domain.com:auth
[submodule "vendor/tools"]
    path = vendor/tools
    url = git@your.cool.domain.com:tools
Run Code Online (Sandbox Code Playgroud)

我们已经正确检查了我们的主存储库'网站'.现在,我的一位同事做了推动,然后我git pull; git status:

# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   vendor/api (new commits)
#   modified:   vendor/auth (new commits)
#   modified:   vendor/tools (new commits) …
Run Code Online (Sandbox Code Playgroud)

git git-submodules

6
推荐指数
1
解决办法
1654
查看次数

如果 Apollo GraphQL 令牌无效或已过期,则 NextAuth.js 注销

在尝试访问后端(Apollo GraphQL)时清除 NextAuth.js 会话的最佳方法是什么,并且由于令牌已过期或无效而返回 401?

我想到了errorLinkand signout,但据我所知signout不能在服务器端使用getServerSideProps,而只能在客户端使用。

推荐的方法是什么?有没有其他方法可以实现中间件来处理这种情况?

这将是errorLink我正在尝试实现的概念的证明,代码被困在其中,if但我无法使用,signOut()因为它仅在客户端可用

const errorLink = onError(({ graphQLErrors }) => {
   if (graphQLErrors?.[0]?.message === 'Unauthenticated.') {
    // signOut();
  }
});

function createApolloClient(session) {
  return new ApolloClient({
    cache: new InMemoryCache(),
    ssrMode: typeof window === 'undefined',
    link: from([
      errorLink,
      createUploadLink({
        uri: GRAPHQL_URI,
        credentials: 'same-origin',
        headers: { Authorization: session?.accessToken ? `Bearer ${session.accessToken}` : '' },
      }),
    ]),
  });
}
Run Code Online (Sandbox Code Playgroud)

谢谢

apollo reactjs graphql next.js next-auth

5
推荐指数
1
解决办法
1121
查看次数

标签 统计

apollo ×1

git ×1

git-submodules ×1

graphql ×1

next-auth ×1

next.js ×1

reactjs ×1