Skip to content

fix: auto-add localhost to trustedOrigins in dev mode #126

@onmax

Description

@onmax

Problem

When NUXT_PUBLIC_SITE_URL points to production (e.g. https://foo.workers.dev), trustedOrigins only contains the production origin. Login from http://localhost:3000 fails with INVALID_ORIGIN.

Expected

In dev mode (import.meta.dev), the module should auto-add http://localhost:${port} to trustedOrigins.

Relevant code

src/runtime/server/utils/auth.tsgetBaseURL() always prioritizes explicit siteUrl, so trustedOrigins never includes localhost.

Suggested fix

When import.meta.dev, pass trustedOrigins: ['http://localhost:3000'] (or detect the actual port) to the betterAuth() config.

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