@@ -403,10 +403,12 @@ async function downloadFileForBase64(fileUrl: string, userId?: string): Promise<
403403 }
404404 return Buffer . from ( base64Data , 'base64' )
405405 }
406- if ( / ^ h t t p s ? : \/ \/ / i. test ( fileUrl ) ) {
406+ if ( / ^ h t t p s ? : \/ \/ / i. test ( fileUrl ) || isInternalFileUrl ( fileUrl ) ) {
407407 return downloadFileWithTimeout ( fileUrl , userId )
408408 }
409- throw new Error ( 'Unsupported fileUrl scheme: only data: URIs and http(s):// URLs are allowed' )
409+ throw new Error (
410+ 'Unsupported fileUrl scheme: only data: URIs, http(s):// URLs, and internal /api/files/serve/ paths are allowed'
411+ )
410412}
411413
412414function processOCRContent ( result : OCRResult , filename : string ) : string {
@@ -801,12 +803,17 @@ async function parseWithFileParser(
801803
802804 if ( / ^ d a t a : / i. test ( fileUrl ) ) {
803805 content = await parseDataURI ( fileUrl , filename , mimeType )
804- } else if ( / ^ h t t p s ? : \/ \/ / i. test ( fileUrl ) ) {
806+ } else if ( / ^ h t t p s ? : \/ \/ / i. test ( fileUrl ) || isInternalFileUrl ( fileUrl ) ) {
807+ // Internal URLs may arrive as an app-relative `/api/files/serve/...` path
808+ // (some ingestion callers store the relative path); downloadFileFromUrl
809+ // resolves it directly against storage without an absolute origin.
805810 const result = await parseHttpFile ( fileUrl , filename , mimeType , userId )
806811 content = result . content
807812 metadata = result . metadata || { }
808813 } else {
809- throw new Error ( 'Unsupported fileUrl scheme: only data: URIs and http(s):// URLs are allowed' )
814+ throw new Error (
815+ 'Unsupported fileUrl scheme: only data: URIs, http(s):// URLs, and internal /api/files/serve/ paths are allowed'
816+ )
810817 }
811818
812819 if ( ! content . trim ( ) ) {
0 commit comments