You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署在app.fleek.co上时NextAuth与IPFS出现404错误

问题描述

我有一个搭载仪表盘的NextJS13项目,采用NextAuth.js的Credentials Provider对接Django后端实现身份验证。本地环境可正常完成仪表盘的登录与退出操作,但部署至app.fleek.co的生产环境后,尝试登录时出现IPFS 404错误。

错误信息

404 Not Found
您请求的内容路径无法找到,可能存在无效或缺失的DAG节点。

failed to resolve /ipfs/bafybeiatukfplopy6hbrlwirxbqjmqtiecg64gjfpxos6qjhtqx3gutrzy/api/auth/error: no link named "api" under bafybeiatukfplopy6hbrlwirxbqjmqtiecg64gjfpxos6qjhtqx3gutrzy

NextAuth代码

import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import axios from "axios";

const BACKEND_ACCESS_TOKEN_LIFETIME = 45 * 60; // 45 minutes
const BACKEND_REFRESH_TOKEN_LIFETIME = 6 * 24 * 60 * 60; // 6 days

const getCurrentEpochTime = () => {
  return Math.floor(new Date().getTime() / 1000);
};

const SIGN_IN_HANDLERS = {
  credentials: async (user, account, profile, email, credentials) => {
    return true;
  },
};
const SIGN_IN_PROVIDERS = Object.keys(SIGN_IN_HANDLERS);

export const authOptions = {
  secret: process.env.NEXTAUTH_SECRET,
  session: {
    strategy: "jwt",
  },
  providers: [
    CredentialsProvider({
      name: "Credentials",
      credentials: {
        email: { label: "Email", type: "text" },
        password: { label: "Password", type: "password" },
      },

      async authorize(credentials) {
        try {
          const response = await axios({
            url: process.env.API_ROUTE + "/api/token/",
            method: "post",
            data: credentials,
          });
          const data = response.data;
          
          if (data) {
            return data;
          }
        } catch (error) {
          console.error(error);
        }
        return null;
      },
    }),
  ],
  callbacks: {
    async signIn({ user, account, profile, email, credentials }) {
      if (!SIGN_IN_PROVIDERS.includes(account.provider)) return false;
      return SIGN_IN_HANDLERS[account.provider](
        user,
        account,
        profile,
        email,
        credentials
      ) ;
    },
    async jwt({ user, token, account }) {
      if (user && account) {
        let backendResponse =
          account.provider === "credentials" ? user : account.meta;
        token.user = backendResponse.user;
        token.access = backendResponse.access;
        token.refresh = backendResponse.refresh;
        token.ref = getCurrentEpochTime() + BACKEND_ACCESS_TOKEN_LIFETIME;
        return token;
      }
      return token;
    },

    async session({ user, token }) {
      return { ...token, user };
    },
  },

  pages: {
    signIn: "/homepage/login",
    error: '/',
  },
};

export default NextAuth(authOptions);

重复出现的错误信息

404 Not Found
您请求的内容路径无法找到,可能存在无效或缺失的DAG节点。

failed to resolve /ipfs/bafybeiatukfplopy6hbrlwirxbqjmqtiecg64gjfpxos6qjhtqx3gutrzy/api/auth/error: no link named "api" under bafybeiatukfplopy6hbrlwirxbqjmqtiecg64gjfpxos6qjhtqx3gutrzy

排查步骤

  • 查看IPFS相关讨论论坛寻找类似错误案例
  • 使用IPFS诊断工具排查请求链路问题
  • 自行部署并运行IPFS客户端验证数据完整性
  • 检查CID或DAG节点是否有效

内容的提问来源于stack exchange,提问作者Rmasona

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 09:51:29