This commit is contained in:
hailin 2025-05-21 02:37:31 +08:00
parent 9f99a02818
commit 6b1ade1ad3
2 changed files with 6 additions and 10 deletions

View File

@ -70,27 +70,20 @@ export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) {
} = useContext(ChatbotUIContext)
const [loading, setLoading] = useState(true)
const [redirected, setRedirected] = useState(false) // 防止重复跳转
useEffect(() => {
;(async () => {
//const supabaseClient = await supabase(); // Await the client creation
const session = (await supabase.auth.getSession()).data.session
//if (!session) {
if (!session && !redirected) {
if (!session) {
// 跳转到带有 locale 的登录页面
setRedirected(true) // 设置标志,避免跳转重复
return router.push(`/${locale}/login`)
} else {
if (!redirected){
await fetchWorkspaceData(workspaceId) // 如果有session则加载工作区数据
}
await fetchWorkspaceData(workspaceId) // 如果有session则加载工作区数据
}
})()
}, [workspaceId, redirected])
}, [])
useEffect(() => {

View File

@ -18,6 +18,9 @@ import { Database } from "@/supabase/types"
// 动态获取 URL防止静态打包成 localhost:8000
const supabaseUrl = getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000"
// 打印获取的 URL
console.log("=======>>Supabase URL:", supabaseUrl);
// 编译时固定匿名 key前端安全公开
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!