【发布时间】:2022-11-16 08:59:31
【问题描述】:
所以 - 如果我尝试访问 +page.js 中的可写对象,那么它只会返回空。
import { isAuthenticated, user } from '../../authstore';
export const load = async ({ fetch }) => {
console.log ('doing load')
console.log('is auth = ', isAuthenticated)
if (! isAuthenticated) {
throw redirect(302, '/');
}
return {test:''};
}
如您所见,我将其添加到 +page.js 以检查登录状态,如果没有,则将它们重定向到根目录。
但是 - isAuthenticated 不可访问。这是因为它在服务器而不是客户端上运行吗?
【问题讨论】: