pedrodiaz
05/24/2022, 5:49 PMJulien
05/24/2022, 9:01 PMDevansh
05/24/2022, 9:51 PMDivineDemon
05/24/2022, 10:46 PMzavbala
05/24/2022, 11:42 PMJingly
05/25/2022, 1:34 AMAlanK
05/25/2022, 4:03 AMjaitaiwan
05/25/2022, 5:05 AMwiesson
05/25/2022, 7:33 AMError: Dynamic require of "stream" is not supported
at worker.js:46:22595
at node_modules/.pnpm/node-fetch@2.6.7/node_modules/node-fetch/lib/index.js (worker.js:46:320543)
at worker.js:46:22757
at node_modules/.pnpm/cross-fetch@3.1.5/node_modules/cross-fetch/dist/node-ponyfill.js (worker.js:46:338800)
at worker.js:46:22757
at node_modules/.pnpm/@supabase+gotrue-js@1.22.15/node_modules/@supabase/gotrue-js/dist/main/lib/helpers.js (worker.js:46:339736)
at worker.js:46:22757
at node_modules/.pnpm/@supabase+gotrue-js@1.22.15/node_modules/@supabase/gotrue-js/dist/main/GoTrueApi.js (worker.js:46:341578)
at worker.js:46:22757
at node_modules/.pnpm/@supabase+gotrue-js@1.22.15/node_modules/@supabase/gotrue-js/dist/main/index.js (worker.js:46:365534)
I think the edge function has access to fetch, so neither node-fetch or cross-fetch should be required here.lanbau
05/25/2022, 8:34 AMLior539
05/25/2022, 9:48 AMYeezy
05/25/2022, 2:49 PMoctalpixel
05/25/2022, 3:32 PMVik
05/25/2022, 5:05 PMconst { user, setUser } = useContext(AuthenticatedUserContext);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
const { data: listener } = supabase.auth.onAuthStateChange(async (_, session) => {
session?.user ? setUser(session.user) : setUser(null);
});
setIsLoading(false);
return () => {
listener?.unsubscribe();
};
}, []);
Gabriel_
05/25/2022, 6:00 PMgustavoeliasexe
05/25/2022, 6:03 PMmetala
05/25/2022, 7:10 PMNeedle
05/25/2022, 8:04 PMNeedle
05/25/2022, 8:39 PMNeedle
05/25/2022, 8:40 PMvinciarts
05/26/2022, 12:39 AMAsaf
05/26/2022, 12:39 AMVik
05/26/2022, 1:16 AMandriusmv
05/26/2022, 2:12 AMMattyfaz
05/26/2022, 4:45 AMjavascript
export default defineNuxtRouteMiddleware((to, _from) => {
const user = useSupabaseUser()
if (!user.value) {
return navigateTo('/login')
}
})
Then on the /login
page I have the following watching for when the user logs in:
javascript
watchEffect(() => {
if (user.value) {
navigateTo('/');
}
});
This works and I can successfully add auth to my routes.
However if I open a new tab and go directly to a protected route it thinks I am not authenticated, therefore sending me to login page, which then identifies I am logged in and redirects me to the index page.Fangio
05/26/2022, 6:40 AMVidski
05/26/2022, 6:49 AMBAN
05/26/2022, 11:58 AMtheuknowner
05/26/2022, 12:20 PM__ianjasper
05/26/2022, 12:38 PM