Skip to content

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

@ppo

Description

@ppo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions