franfernandez
05/16/2022, 9:40 PMjs
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.Needle
05/16/2022, 9:40 PMgaryaustin
05/16/2022, 9:46 PMNeedle
05/16/2022, 9:46 PMfranfernandez
05/16/2022, 9:56 PMfranfernandez
05/16/2022, 9:57 PMjs
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
},
}