I’m making a WordPress plugin to show a server’s file structure on a webpage. Everything works, but there’s a weird problem.
When I build the data on the server, it looks fine. Each item has its name, path, type, and any sub-items. But when I check the console on the frontend, the main folder paths are wrong. The sub-items are okay though.
Here’s a quick example of what I mean:
Server output (correct):
{
name: 'folder1',
path: 'folder1',
type: 'folder',
children: [
{
name: 'subfolder1_1',
path: 'folder1/subfolder1_1',
type: 'folder',
children: [
{
name: 'file.txt',
path: 'folder1/subfolder1_1/file.txt',
type: 'file'
}
]
}
]
}
Frontend console (wrong):
{
name: 'folder1',
path: 'base_folder1/folder1',
type: 'folder',
children: [
{
name: 'subfolder1_1',
path: 'folder1/subfolder1_1',
type: 'folder',
children: [
{
name: 'file.txt',
path: 'folder1/subfolder1_1/file.txt',
type: 'file'
}
]
}
]
}
See how the top-level path changed? I’m not modifying the data anywhere, so I’m confused. Any ideas what could cause this?