fix 500 when setting root as public root

When listing root children, the path should omit a colon

Ref https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online#list-children-in-the-root-of-the-current-users-drive
This commit is contained in:
myl7
2021-11-01 18:35:34 +08:00
parent 6f057734d4
commit 9ad71b2675
+5 -2
View File
@@ -91,8 +91,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
}
const requestPath = encodePath(path)
// Handle response from OneDrive API
const requestUrl = `${apiConfig.driveApi}/root${encodePath(path)}`
const requestUrl = `${apiConfig.driveApi}/root${requestPath}`
// Whether path is root, which requires some special treatment
const isRoot = requestPath === ''
// Go for file raw download link and query with only temporary link parameter
if (raw) {
@@ -124,7 +127,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
})
if ('folder' in identityData) {
const { data: folderData } = await axios.get(`${requestUrl}:/children`, {
const { data: folderData } = await axios.get(`${requestUrl}${isRoot ? '': ':'}/children`, {
headers: { Authorization: `Bearer ${accessToken}` },
params: next
? {