© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
12 replies
jax

Cannot read properties of null (reading 'split')

there is a error when I use exchangeCodeForSession. I has a question, exchangeCodeForSession is running on server , why was the ${this.storageKey}-code-verifier
)  set???

this is my callback code:
export  default async function handler(
  req: NextApiRequest,
  res: NextApiResponse<Data>
) {
  const code = req.query['code'] as string
  
  const origin = 
)  set???

this is my callback code:
export  default async function handler(
  req: NextApiRequest,
  res: NextApiResponse<Data>
) {
  const code = req.query['code'] as string
  
  const origin = 
http://${req.headers.host}`

if (code) {
const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
get(name: string) {
return req.cookies[name];
},
set(name: string, value: string, options: CookieOptions) {
res.setHeader("Set-Cookie", serialize(name, value, options));
},
remove(name: string, options: CookieOptions) {
res.setHeader("Set-Cookie", serialize(name, "", options));
},
}
},

)
await supabase.auth.exchangeCodeForSession(code)
}


// URL to redirect to after sign in process completes
res.redirect(origin);
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

signOut TypeError Cannot read properties of null (reading 'user') -- Next.js
SupabaseSSupabase / help-and-questions
4y ago
Cannot read properties of undefined (reading 'user') sveltekit auth-helpers
SupabaseSSupabase / help-and-questions
4y ago
Supabase gen types cannot read properties of undefined
SupabaseSSupabase / help-and-questions
4mo ago
Conf Email redirect error: Uncaught TypeError: Cannot read properties of undefined (read 'includes')
SupabaseSSupabase / help-and-questions
7mo ago