SERVER_ONLY_PROPERTY on apiKey plugin even though the call is using the server instance
This is my code
And I get this error
5 Replies
@Better Auth
Hi there! I’m Better Auth—your friendly bot for all things related to our authentication framework. I noticed you mentioned @Better Auth, but I’m not quite sure what question you have in mind. Could you clarify what aspect of Better Auth you need help with? Are you experiencing an issue or looking for guidance on integration or configuration? Let me know so I can assist you better!
— Better Auth is powered by https://clarm.com
@Better Auth
This is my code
And I get this error
It looks like the error
appears because you’re including a property (in this case, the permissions field) that isn’t allowed to be set via the API endpoint call. In Better Auth, certain properties (like permissions) are meant to be configured directly on the server instance—not provided ad hoc in an API request—even when you’re running in a server context [2].
To fix the issue you have a couple of options:
• Remove the permissions field from your request body and let the API use the default permissions as set in your configuration,
• Or, if you need to assign custom permissions upon creation, adjust your Better Auth server configuration so that this field can be managed internally. Does this match what you expect from your API key creation flow? Let me know if you’d like to discuss other configuration details or if you have additional questions! Sources: [2] insert permissions on server side — Better Auth is powered by https://clarm.com
• Remove the permissions field from your request body and let the API use the default permissions as set in your configuration,
• Or, if you need to assign custom permissions upon creation, adjust your Better Auth server configuration so that this field can be managed internally. Does this match what you expect from your API key creation flow? Let me know if you’d like to discuss other configuration details or if you have additional questions! Sources: [2] insert permissions on server side — Better Auth is powered by https://clarm.com
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
insert permissions on server side · Issue #1665 · better-auth/bet...
Is this suited for github? Yes, this is suited for github To Reproduce static async createApiKey( headers: IncomingHttpHeaders, data: CreateApiKeyDto, ) { console.log(data); const apikey = await au...
@Max @Alex Yang
Can anyone please have a look at this issue? The permissions field isn't configurable on the server or the client
The bot found a github issue https://github.com/better-auth/better-auth/issues/1665
GitHub
insert permissions on server side · Issue #1665 · better-auth/bet...
Is this suited for github? Yes, this is suited for github To Reproduce static async createApiKey( headers: IncomingHttpHeaders, data: CreateApiKeyDto, ) { console.log(data); const apikey = await au...