Dify本地初始化后安装模型供应商瞬间失败控制台报错401
Dify本地初始化后安装模型供应商瞬间失败控制台报错401
1. 错误背景
依照 Dify 官方网站的指导说明,使用 Docker Compose 启动 Dify,然后访问浏览器登录 Dify Web 页面,参考命令如下:
# 命令来自 Github https://github.com/langgenius/dify?tab=readme-ov-file#quick-start
cd dify
cd docker
cp .env.example .env
docker compose up -dAfter running, you can access the Dify dashboard in your browser at http://localhost/install and start the initialization process.
2. 问题现象及解决办法
当你从浏览器中访问 http://localhost/install 正常初始化 Dify 后,下一步就要去“设置”-“模型供应商”,去“安装模型供应商”,当你点击安装后马上提示失败,然后打开浏览器控制台查看会有类似下面的 401 错误( 401 (UNAUTHORIZED) ):
59556-8fdf45455faf8e46.js:1 GET http://localhost/console/api/workspaces/current/default-model?model_type=speech2text 401 (UNAUTHORIZED)
ui @ 79d472a6-5af6d214571a09f4.js:1了解此错误
59556-8fdf45455faf8e46.js:1 GET http://localhost/console/api/workspaces/current/default-model?model_type=tts 401 (UNAUTHORIZED)
解决办法
其实这个主要的原因是因为你访问的 URL 导致的,上面我们顺理成章的继续接着 http://localhost/install 进行访问,此时,你查看自己本机电脑 IP,使用 IP地址访问,这个问题便能解决:
例如,我从 http://localhost/apps 切换为 http://192.168.64.1/apps 即能正常访问并安装“模型供应商”。