Unexpected path discrepancy in directory structure between server and client

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?

This discrepancy suggests a potential issue with path handling on the client side. It’s possible that your JavaScript code is prepending a base directory to the top-level paths. Check your client-side script for any functions that modify paths, especially those handling AJAX responses or data processing. Also, verify if you’re using any WordPress plugins that might interfere with path handling. Consider implementing a debug log on both server and client sides to track the data at various stages of transmission and processing. This will help pinpoint exactly where the path alteration occurs.

hmm, weird issue. could be a wordpress hook or filter doin’ some sneaky stuff. have u checked ur wp-config.php? sometimes there’s base path settings there that mess with things. also, try echoing the data right before sendin’ it to the frontend, see if it’s still good then.

hey, this is puzzlin’! maybe a js function or a wordpress filter is tackin’ on a base prefix to your main folder? have u logged the data right after reception? curious if any config or server setting might be at play. what do u think?