Configuration
To make my project run locally on foo.test instead of localhost, I did this…
package.json:
"scripts": {
"dev": "next dev -H foo.test --turbopack",
.env:
BASE_URL=http://foo.test:3000
Restart the dev server.
Problem
I can sign in and access the dashboard but the auth is not persistent (top navbar doesn't switch to authenticated version and not authenticated anymore when refreshing the page).
Solution
lib/auth/session.ts:
export async function setSession(user: NewUser) {
// …
secure: process.env.NODE_ENV === 'production', // Instead of `true`
// …