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
https://cookies will be secured by default if you don't specify theuseSecureCookiesoption.
and the function is only prefixing the cookie__secure-in production ignoring the code above
request.nextUrl.origin.startsWith("https://" to add the secure prefix.