Issue using wixLocation.query with wixWindow.rendering.renderCycle === 1 on HOME page

Hello WIX team,

I’m using “if (wixWindow.rendering.renderCycle === 1)” to run part of my code once.
To upload some language specific strings from backend collection, I’m checking which language is currently set in URL with the following:
let language = wixLocation.query[“lan”]; // while URL is https://myuser.wixsite.com/mysite?lan=en

It works for all the pages, but surprisingly not for home page.
At rendering cycle === 1, I see that “language” is undefined in case it is backend rendering cycle. Once browser “onReady” starts running, I get the proper value (“en”) in “language” variable.

Is there some known limitation / bug for home page with rendering cycle running on backend?

BTW, I tried also wixLocation.url. At home page, during backend rendering (cycle === 1) it returns
https://myuser.wixsite.com/mysite
while on browser rendering cycle it returns the expected url:
https://myuser.wixsite.com/mysite?lan=en

Thanks,
Dima

1 Like

Hi Dima!

Please share either a link to your site with the relevant issue or the code that you use so one of our WixCode team can inspect it and provide you with a solution.

Doron.

Hi Doron,

Thanks for the help.
I created sample site with 2 relevant pages which demonstrate the issue I described above.

First page: https://dmitrybi32.wixsite.com/issue-reproduce?item=sample
This one is regular home page. It reproduces the issue I described, you may see it on the page itself.

The second page: https://dmitrybi32.wixsite.com/issue-reproduce/router-test?item=sample
This is router page. I just copy-pasted home page’s onReady code, as well text elements to this page, so they are “identical” for the purpose of this reproduce.

In first case you may see that on cycle 1 and on cycle 2 different results are displayed (invalid query and url on the cycle 1), while on the second page the results are similar on both cycles.

The issue demonstrated here on “home” page. But actually according to my observation it happens on all regular pages.

I’ll appreciate to hear some update on this problem :slight_smile:

Thanks,
Dima

Hi again Dima!

After inspecting the issue you described we found that it might be a bug on our side.
As soon as we resolve this issue I’ll be glad to update this thread and let you know.

Thank you for your patience,

Doron.

Thanks, Doron!
Waiting for update.

Dima

Hi Dima!
Sorry for leaving you hanging for so long with this.

After we have consulted with the relevant team we concluded that the above behavior isn’t a bug,
But misuse / misunderstanding of a very complicated subject and of the feature.

Server-Side-Rendering works only for first page to load. All navigations inside the site are on the client-side only.
Since wixLocation is a front-end method all the rendering of the following pages happens on the client side.
Therefore the backend has no access to the wixLocation.query and that’s why we get an error.

I hope thats clarifies the subject of the thread.
Let me know if you need more information!

Doron.

Hi Doron.

I agree with you that not all functionality is available on backend rendering cycle.

However I’m not sure I agree with your conclusion regarding the issue I observe due to the following observations:

  1. In case wixLocation is not available I would expect that wixLocation.url will return null. However it returns base URL instead of current URL. So it feels it just works incorrectly.

  2. The second and more important in my opinion, is that wixLocation functionality works correctly on first rendering cycle on router pages, including wixLocation.query method.

Is it possible to check once again with teams who work on rendering cycles / performance related features?

Thanks,
Dima

Doron,
from my tests it looks like bug was fixed.
Could you please confirm? Or it is just some temporary correct behavior?
Thanks,
Dima

Hi @_dima !

I will check again and update shortly.
Thanks for letting us know!

Doron.

Hi @doron-alkalay ,
Looks issue is back again (or I was mistakenly thinking it is not reproducing anymore).
Did you have a chance to check it from your side?
Thanks,
Dima

Hi @_dima !

Thanks for bringing it to our attention.
We’re looking for the cause of the problem and we’ll fix it as soon as possible.
And of course that we will let you know as soon as a solution is found.

Doron.

Hey @_dima !

According to our tests there might be a problem with the SDK that affect the SSR indirectly.
Meanwhile I’d suggest you to try and use the wixWindow.locale method as a temporary workaround instead of the query params.

Let me know if it works for you, and again, I’ll make sure to inform you as soon as the issue is resolved.

Doron.