@@ -2,7 +2,7 @@ import { createReadStream } from 'fs';
22import { resolve , join } from 'path'
33import { config } from "@/config" ;
44import { load_json_abs } from '@/libs/utils.js'
5- import { file_mime } from '@/libs/assets.js'
5+ import { exists , file_mime } from '@/libs/assets.js'
66import { remove_base } from '@/libs/assets.js'
77
88export async function GET ( { params} ) {
@@ -14,7 +14,16 @@ export async function GET({params}){
1414 imagePath = resolve ( join ( config . rootdir , "public" , params . path ) ) ;
1515 }
1616 imagePath = remove_base ( imagePath )
17- console . log ( `assets> serving '${ imagePath } '` )
17+ //due to a markdown limitation, abs assets are stripped of starting '/' in linux
18+ //workaround : if the file does not exist, then try the public
19+ if ( ! await exists ( imagePath ) ) {
20+ imagePath = resolve ( join ( config . rootdir , "public" , params . path ) ) ;
21+ }
22+ if ( ! await exists ( imagePath ) ) {
23+ console . log ( `\nassets> * NOT FOUND ${ params . path } ` )
24+ } else {
25+ console . log ( `\nassets> serving '${ imagePath } '` )
26+ }
1827 try {
1928 const stream = createReadStream ( imagePath ) ;
2029 const contentType = file_mime ( imagePath )
0 commit comments