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
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.
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.
Thanks, Doron!
Waiting for update.
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.
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 :)
Thanks,
Dima
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.