Hello. I'm having some problems to find the best w...
# help
f
Hello. I'm having some problems to find the best way to auth on server side with NextJs integration. I'm trying to handle the token like is mentioned in the docu (https://supabase.com/docs/reference/javascript/auth-setauth)
Copy code
js
export default async function handler (req, res) {
  const { access_token } = req.get('X-Supabase-Auth')
  const { user, error } = supabase.auth.setAuth(access_token)

  console.log('error', error)
  console.log('user', user)
}
but with NextJs middleware is becoming difficult,
req.get
is not defined. There are some documentation about this behaviour.
n
Hello @franfernandez! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
g
n
franfernandez (2022-05-16)
f
Thank you @garyaustin. Thats great. I see something interesant but not is exactly align which what I was trying.
And I'm tryong to pass the token as is documented
Copy code
js
 const response = await fetch('http://localhost:3000/api/account/', {
              method: 'POST',
              withCredentials: true,
              credentials: 'include',
              headers: {
                'Content-Type': 'application/json',
                'X-Supabase-Auth': token // Set the Supabase user
              },
}