saas-starter icon indicating copy to clipboard operation
saas-starter copied to clipboard

[SOLVED] Auth not working when running on `.test` host

Open ppo opened this issue 5 months ago • 0 comments

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`
    // …

ppo avatar Aug 16 '25 17:08 ppo