getSessionCookie() return null is some cases
its confusing for some of us that
getSessionCookie() is not behaving like we expect for the next reasons:- the function is not respecting the auth options specified in
auth.ts
because if you import the config option it will not be compatible with edge runtime. therefore you should specify the config as the second argument if cookie name or prefix is customized. - in dev mode if you are running your server in
cookies will be secured by default if you don't specify thehttps://
option.useSecureCookies
and the function is only prefixing the cookie
in production ignoring the code above__secure-
request.nextUrl.origin.startsWith("https://" to add the secure prefix.