nestjs-paginate
nestjs-paginate copied to clipboard
Remove the host & protocol part of the links section using the `origin` property
I wanted to perform this and I thought it's gonna work:
const dbEntries = await paginate(query, this.clientsRepo, {
sortableColumns: getColumns(this.clientsRepo, true).names,
select: getColumns(this.clientsRepo, true).names,
origin: '', // 👈
})
But it didn't, I wanted to change the links.cuurent
origin, from:
"links": {
"current": "http://localhost:3001/clients?page=1&limit=20&sortBy=accountType:ASC&select=username,accountType"
}
to
"links": {
"current": "/clients?page=1&limit=20&sortBy=accountType:ASC&select=username,accountType"
}
But it doesn't work, I also tried to put "/"
, but it resulted in double slashes as follows:
"links": {
"current": "//clients?page=1&limit=20&sortBy=accountType:ASC&select=username,accountType"
}
I think this is because the library somewhere in its code checks on the property if it exists by some approach like this:
if(!!origin) { /* do the `origin` logic */ }
I think it should handle this case by something like this:
if(origin == "" || !!origin) { /* do the `origin` logic */ }