Skip to content

High performance self-hosted photo and video management solution.

fix(server): Properly build ML predict URL (#9751)

safehome-jdev4d4bb8b6a71b
diff --git a/server/src/repositories/machine-learning.repository.ts b/server/src/repositories/machine-learning.repository.ts
index 3d8f0cac1e..bff22b9507 100644
--- a/server/src/repositories/machine-learning.repository.ts
+++ b/server/src/repositories/machine-learning.repository.ts
@@ -19,9 +19,11 @@ export class MachineLearningRepository implements IMachineLearningRepository {
private async predict<T>(url: string, input: TextModelInput | VisionModelInput, config: ModelConfig): Promise<T> {
const formData = await this.getFormData(input, config);
- const res = await fetch(`${url}/predict`, { method: 'POST', body: formData }).catch((error: Error | any) => {
- throw new Error(`${errorPrefix} to "${url}" failed with ${error?.cause || error}`);
- });
+ const res = await fetch(new URL('/predict', url), { method: 'POST', body: formData }).catch(
+ (error: Error | any) => {
+ throw new Error(`${errorPrefix} to "${url}" failed with ${error?.cause || error}`);
+ },
+ );
if (res.status >= 400) {
const modelType = config.modelType ? ` for ${config.modelType.replace('-', ' ')}` : '';