Next.js Discord

Discord Forum

Expo webview Headers problems. Nextjs, Supabase Subscriptions problems

Answered
Siamese Crocodile posted this in #help-forum
Open in Discord
Siamese CrocodileOP
im based off of: https://github.com/vercel/nextjs-subscription-payments

and i am building a mobile app with webview of that github repo.

So i want to access: https://github.com/vercel/nextjs-subscription-payments + /dashboard

------------------------------------------------------------------------------------------------------------------
<Tab.Screen name="Dashboard2">
{props =>
<WebView
source={{
uri: 'https://github.com/vercel/nextjs-subscription-payments/dashboard',
headers: {
'Authorization': ${session.access_token},
'Reference': ${session.refresh_token}
}
}}
/>
------------------------------------------------------------------------------------------------------------------

I have a folder called Dashboard under App folder in the github repo.

And I put the code for accessing the headers in page.tsx:

------------------------------------------------------------------------------------------------------------------

export default async function Account() {

const headersList = headers()
const autho = headersList.get('Authorization') as string
const refero = headersList.get('Reference') as string

console.log("refero boi", refero)

const supabase = createServerSupabaseClient();

let lagos = null;

const { data, error } = await supabase.auth.setSession({
access_token: autho,
refresh_token: refero,
})
lagos = data.session;

console.log("LEHO",lagos)

------------------------------------------------------------------------------------------------------------------

Sometimes it console logs null sometimes it console logs the lagos and refero and autho.


When i check the logs on my android simulator it shows that i did get session.

However I don't think my middleware or the rest of the app got the session.

It brings me to my dashboard page, says it has session. but for some reason shows nothing.



I think it has something to do with setting Session but it not being set in the cookies.
Answered by Siamese Crocodile
solved: i moved setsession in middleware, and stopped trying to set the cookies myself.

I believe its because nextjs you can read cookies in server components but not set them
View full answer

1 Reply

Siamese CrocodileOP
solved: i moved setsession in middleware, and stopped trying to set the cookies myself.

I believe its because nextjs you can read cookies in server components but not set them
Answer