There is currently an issue with Next.js where setting a cookie using cookies() and then returning NextResponse will not add the cookie to that response meaning that the session is not set and requires a refresh. This adds the cookie to the response along side setting it using cookies() to make sure that upon redirecting, the session is present.
Test Plan
I manually tested this, both as a fresh install, on existing projects and had confirmation from others that this approach worked when they were using this as repo as a starting point.
What does this PR do?
There is currently an issue with Next.js where setting a cookie using
cookies()
and then returningNextResponse
will not add the cookie to that response meaning that the session is not set and requires a refresh. This adds the cookie to the response along side setting it usingcookies()
to make sure that upon redirecting, the session is present.Test Plan
I manually tested this, both as a fresh install, on existing projects and had confirmation from others that this approach worked when they were using this as repo as a starting point.
Related PRs and Issues
Have you read the Contributing Guidelines on issues?
Yes