Cant delete API_Key
I get 404 when using the delete.
_
const handleDelete = async () => {
if (!selectedKey) return;
setLoading(true); try { // Log the key ID for debugging console.log('Attempting to delete API key with ID:', selectedKey.id); const { data: result, error } = await authClient.apiKey.delete({ keyId: selectedKey.id, }); -------------------------------------------------- I can create, edit, list, just cant delete them.
setLoading(true); try { // Log the key ID for debugging console.log('Attempting to delete API key with ID:', selectedKey.id); const { data: result, error } = await authClient.apiKey.delete({ keyId: selectedKey.id, }); -------------------------------------------------- I can create, edit, list, just cant delete them.


8 Replies
anyone? :c I cant get it to work so it has to be a bug. I will just do it manually for now.
The PR with this fix is merged, should be fixed by next release.
Solution
I am glade I am not crazy, I though I was doing something wrong.
It also didnt work on server!
It also didnt work on server!
Can you show me your auth config?
you mean this?
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "../db";
import * as schema from "../db/schema";
import { apiKey } from "better-auth/plugins";
export const auth = betterAuth({
plugins: [
// Use default options for apiKey plugin
apiKey(),
],
database: drizzleAdapter(db, {
provider: "pg",
schema: schema,
}),
trustedOrigins: [process.env.CORS_ORIGIN!],
emailAndPassword: {
enabled: true,
},
});
Looks about right.
Not sure what could be wrong, but we have unit-tests to make sure this works on the server auth api
I am telling you man everything works but the delete