Hey all. I haven't worked on this website's back end in quite a long time. Basically since I initially deployed it back in 2022. I also haven't made a deployment for the past month. Today the restricted routes give me a 500 error.
I have a route thats restricted to authorized accounts. I ended up doing it in a really janky way by giving the Firebase database read and write privilege only to accounts with a hardcoded Google account UID. In addition, i restricted the ability to login to emails matching our domain. I totally forget how I did that, but that part seems to still be functioning correctly.
The issue occurs in both production and dev. I'll do my best to provide as much info, any help would be greatly appreciated
import { useSession, getSession, signIn, signOut as nextSignOut } from "next-auth/react"
import { getAuth, signInWithCustomToken, signOut as fbSignOut } from "firebase/auth";
import { useEffect } from "react";
const Dashboard = () => {
const { data: session } = useSession({
required: true,
onUnauthenticated() {
signIn()
}
})
const auth = session ? getAuth() : null
if (!session) {
signInWithCustomToken(auth, session.fbLoginToken)
}
return (
<Component />
)
}
export async function getServerSideProps(context) {
return {
props: {
session: await getSession(context),
},
}
The session object returns as null after calling useSession() which I don't think was the case before.
I tried accessing a child route on production, this time it actually forwarded me to the login route but clicking on the login button re-routed me to the same page. I was able to get this error to show up which seems like progress 🤣 :
[next-auth][error][CLIENT_FETCH_ERROR]
https://next-auth.js.org/errors#client_fetch_error Failed to fetch {error: {…}, url: '/api/auth/providers', message: 'Failed to fetch'}