How does the koa2 server return the full path?

question: at present, what images are stored in mongodb is only a relative drive, so how to provide a complete image path to the server when returning to the front end?

in the database:

/products/img1.png

actual returned data:

http://xxx.xxx.xxx.xxx:8000/images/products/img1.png

requirement: the client can access the image directly according to the path.

Nov.26,2021

just bring it up and deal with it:

const BaseUrl = 'http://xxx.xxx.xxx.xxx:8000/images';

router.get('/', async (ctx) => {
    let docs = await Images.find({});
    docs = docs.map(doc => ({...doc._doc, full_url: BaseUrl + doc.url}));
    ctx.body = {data: docs}
});

you can use window.location.href, and then splice paths

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8a097-46d7f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8a097-46d7f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?