fix(auth): validate Coding Plan API key prefix for China region

- Add validation to check API key starts with "sk-sp-" for China region
- Add Chinese translation for the validation error message
- Only apply prefix validation when region is aliyun.com (China)

This prevents users from submitting invalid API keys for the China region, providing immediate feedback with a localized error message.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-03-02 21:19:41 +08:00
parent 112318d092
commit fa5bd26b68
2 changed files with 14 additions and 0 deletions

View file

@ -49,6 +49,18 @@ export function ApiKeyInput({
setError(t('API key cannot be empty.'));
return;
}
// Only validate sk-sp- prefix for China region (aliyun.com)
if (
region === CodingPlanRegion.CHINA &&
!trimmedKey.startsWith('sk-sp-')
) {
setError(
t(
'Invalid API key. Coding Plan API keys start with "sk-sp-". Please check.',
),
);
return;
}
onSubmit(trimmedKey);
}
},