Skip to content

routeRules auth config not typed #164

@larrasu

Description

@larrasu

When using the admin plugin and adding roles to the routeRules auth config:

routeRules: {
    '/admin/**': { auth: { user: { role: 'admin' } } }, // Object literal may only specify known properties, and role does not exist in type
    '/login': { auth: 'guest' },
  },

I did augment the AuthUser type but it's still not type-safe:

import '#nuxt-better-auth'

declare module '#nuxt-better-auth' {
  interface AuthUser {
    role: 'user' | 'admin'
    ...
  }
}

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