You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In core/lib/multistore.ts::storeCodeFromRoute if matchedRouteOrUrl is an object but is missing the host property, the current logic simply returns an empty string if the first store in the store loop does not match. The logic is basically the following:
Iterate all stores from mapStoreUrlsFor
In each iteration, create normalizedPath from matchedRouteOrUrl.path (if object)
If normalizedPath doesn't match the store code in the current iteration, check if matchedRouteOrUrl is an object.
If it IS an object, and it doesn't have ['host'] then return ''.
The problem here is only the first store is checked under these conditions. The specific scenario where I discovered this is when I am on a product view and I try to load it server side, it fails and redirects to page not found. I'm not sure why the route object doesn't have host, but this is what's causing this break in the loop.
Expected behavior
It should follow the same logic as when matchedRouteOrUrl is a string. So instead of return '', it should either continue, or set url = normalizedPath.
Steps to reproduce the issue
I'm not sure if there's something in our environment that is causing this scenario to work this way, but how we produced it is:
Enable multistore with at least two stores active.
Go to a product view on a store that is 2nd or later in the list of mapStoreUrlsFor.
Refresh the page.
Repository
Can you handle fixing this bug by yourself?
YES
NO
Which Release Cycle state this refers to? Info for developer.
Pick one option.
This is a bug report for test version on https://test.storefrontcloud.io - In this case Developer should create branch from develop branch and create Pull Request 2. Feature / Improvement back to develop.
This is a bug report for current Release Candidate version on https://next.storefrontcloud.io - In this case Developer should create branch from release branch and create Pull Request 3. Stabilisation fix back to release.
This is a bug report for current Stable version on https://demo.storefrontcloud.io and should be placed in next stable version hotfix - In this case Developer should create branch from hotfix or master branch and create Pull Request 4. Hotfix back to hotfix.
Environment details
Node: 10.16
Code Version: v1.10.2
The text was updated successfully, but these errors were encountered:
I was looking at this function and this return when there is no host is unnecessary and it breaks the loop as you @rain2o mentioned. We can even delete it because when there is no matches at the end function returns empty string. Deleting this line solves the problem. I'll prepare PR with a little bit refactoring this one & check if everything works properly
Current behavior
In
core/lib/multistore.ts::storeCodeFromRoute
ifmatchedRouteOrUrl
is an object but is missing thehost
property, the current logic simply returns an empty string if the first store in the store loop does not match. The logic is basically the following:mapStoreUrlsFor
normalizedPath
frommatchedRouteOrUrl.path
(if object)normalizedPath
doesn't match the store code in the current iteration, check ifmatchedRouteOrUrl
is an object.['host']
then return''
.The problem here is only the first store is checked under these conditions. The specific scenario where I discovered this is when I am on a product view and I try to load it server side, it fails and redirects to page not found. I'm not sure why the route object doesn't have
host
, but this is what's causing this break in the loop.Expected behavior
It should follow the same logic as when
matchedRouteOrUrl
is a string. So instead ofreturn ''
, it should eithercontinue
, or seturl = normalizedPath
.Steps to reproduce the issue
I'm not sure if there's something in our environment that is causing this scenario to work this way, but how we produced it is:
mapStoreUrlsFor
.Repository
Can you handle fixing this bug by yourself?
Which Release Cycle state this refers to? Info for developer.
Pick one option.
develop
branch and create Pull Request2. Feature / Improvement
back todevelop
.release
branch and create Pull Request3. Stabilisation fix
back torelease
.hotfix
ormaster
branch and create Pull Request4. Hotfix
back tohotfix
.Environment details
The text was updated successfully, but these errors were encountered: