Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
If we add a global URL parameter - like:
/api/:store_code/user/login as an addition to current routes: /api/user/login we'll be able to run the multi-website configuration of the vue-storefront-api
OR we can set the store_code as an HTTP header - like X-VS-Store - which is probably the easier way to handle the vue-storefront part (see below - the second step)
The second thing is to modify the default.json config and then the api adapter instantiation. Currently, we have the config like this:
So - to have the default config + config per store. If the api is called with the "store_code" paramter - we simple are querying the different ES index + differnt rest api endpoints
In the second step - we need to add the parameter to the vue-storefront config:
changing the vue-storefront/config/default.json from:
Then we need to change the API endpoints by adding the store_code to the URL of the API endpoint or as a header (regarding which option has been chosen in the step 1).
... and change the core/scripts/installer.js accordingly. Please note that we have api{{store_code}}/ and not api/{{store_code}} to support the default situation when no store-code is provided because of the last step :)
Last step we need to is to add store_code to the network calls:
Regarding #1134
If we add a global URL parameter - like:
/api/:store_code/user/login
as an addition to current routes:/api/user/login
we'll be able to run the multi-website configuration of the vue-storefront-apiOR we can set the
store_code
as an HTTP header - likeX-VS-Store
- which is probably the easier way to handle the vue-storefront part (see below - the second step)The second thing is to modify the default.json config and then the api adapter instantiation. Currently, we have the config like this:
What we need to have is:
So - to have the default config + config per store. If the api is called with the "store_code" paramter - we simple are querying the different ES index + differnt rest api endpoints
In the second step - we need to add the parameter to the vue-storefront config: changing the vue-storefront/config/default.json from:
to:
.. and change it in all the occurences.
Then we need to change the API endpoints by adding the
store_code
to the URL of the API endpoint or as a header (regarding which option has been chosen in the step 1).If we like to change the urls we need to change:
to sth like:
... and change the
core/scripts/installer.js
accordingly. Please note that we haveapi{{store_code}}/
and notapi/{{store_code}}
to support the default situation when no store-code is provided because of the last step :)Last step we need to is to add store_code to the network calls:
https://github.com/DivanteLtd/vue-storefront/blob/ecd5eb0a7eddc112342771587bf3ac0e868feb00/core/store/lib/task.js#L27
We can use just the .. replace method to replace {{store_code}} with the currently selected store.
The current store selector is a different task: https://github.com/DivanteLtd/vue-storefront/issues/881
The currently selected store should be saved in the localForage:
and in the
store.state.user.currentStore
vuex variable