Skip to content

Commit 69463c3

Browse files
committed
add endpoint url validation
1 parent c99d7b1 commit 69463c3

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/versions

app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/versions/page.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,24 @@ export default function VersionsPage() {
463463

464464
const endpointRequiredProviders = ['CUSTOM', 'LLAMA_OLLAMA', 'LLAMA_CUSTOM'];
465465
const isEndpointRequired = endpointRequiredProviders.includes(providerFormData.provider);
466+
466467
if (isEndpointRequired && !providerFormData.apiEndpointUrl?.trim()) {
467468
toast('Endpoint URL is required for the selected provider.');
468469
return;
469470
}
470471

471-
// Parse apiRequestTemplate string to JSON if provided
472+
if (providerFormData.apiEndpointUrl?.trim()) {
473+
try {
474+
const url = new URL(providerFormData.apiEndpointUrl);
475+
if (!['http:', 'https:'].includes(url.protocol)) {
476+
toast('Endpoint URL must use HTTP or HTTPS protocol.');
477+
return;
478+
}
479+
} catch {
480+
toast('Please enter a valid endpoint URL (e.g., https://api.example.com/v1/chat)');
481+
return;
482+
}
483+
}
472484
let parsedRequestTemplate = null;
473485
if (providerFormData.apiRequestTemplate) {
474486
try {

0 commit comments

Comments
 (0)