This commit is contained in:
parent
9f99a02818
commit
6b1ade1ad3
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue