mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-14 10:48:20 +02:00
feat(openrouter): validate API key at save time
The stored key that caused the persistent 401s turned out to be only 9 characters long — an accepted-but-truncated paste. Prevent this class of problem at the source: - require a minimum key length in the zod schema - verify new keys against OpenRouter's /api/v1/key endpoint on save, rejecting explicit 401/403 (network errors don't block saving) - return zod validation messages as 400 instead of a generic 500 - surface the server's error message in the settings toast (desktop and mobile) instead of a generic failure text
This commit is contained in:
5 files changed
+48
-6
No files matched your search
+1
-1
@@ -394,7 +394,7 @@ export const insertOpenrouterConfigSchema = createInsertSchema(openrouterConfig)
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
}).extend({
|
||||
apiKey: z.string().trim().min(1, "La clé API ne peut pas être vide"),
|
||||
apiKey: z.string().trim().min(20, "La clé API OpenRouter semble incomplète. Collez la clé entière (elle commence par sk-or-v1- et fait environ 73 caractères)."),
|
||||
});
|
||||
|
||||
export const updateOpenrouterConfigSchema = insertOpenrouterConfigSchema.partial({
|
||||
|
||||
Reference in new issue
Block a user