Window.location.pathname not correct on playcanvas hosted builds

Hi

I’m using window.location.pathname to add query strings in runtime and manipulating the window.history to update the url.

in launch mode this works fine, however, if I build and host this app at playcanv.as, I get a mismatch between the location pathname reported in my code and the one I see if I run the command in the browser console.

https://playcanv.as/b/rI5E9xJb/

  1. Code reports window.location.pathname="/index/prm1w5fO/"
  2. Browser console reports window.location.pathname="/b/prm1w5fO/"

This messes up my url, and query string is never updated. What’s going on here?

The published build is iframed.

You can try making it non framed by adding an /e before the /b in the URL.

Eg
https://playcanv.as/e/b/prm1w5fO/

1 Like

ah that’s why. I also tried exchanging /b/ for /index/ which worked.

1 Like