Skip to content

Commit

Permalink
fix(theme): SSR render broken by cookie exception (#195)
Browse files Browse the repository at this point in the history
* wip(theme): update contextToken only if has changed

* test: setting cookie after server response

* chore: cleanup data
  • Loading branch information
patzick authored Dec 9, 2019
1 parent f7ff086 commit c61ee74
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/composables/src/hooks/useCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const useCart = (): any => {
vuexStore.commit("SET_CART", result);
} catch (e) {
error.value = e;
console.error("Problem with fetching data", e.message);
console.error("Problem with fetching CART data", e.message);
console.error(e);
} finally {
loading.value = false;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/composables/src/hooks/useCms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const useCms = (): any => {
vuexStore.commit("SET_PAGE", result);
} catch (e) {
error.value = e;
console.error("Problem with fetching data", e.message);
console.error("Problem with fetching CMS data", e.message);
console.error(e);
} finally {
loading.value = false;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/composables/src/hooks/useProduct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const useProduct = (
return result;
} catch (e) {
error.value = e;
console.error("Problem with fetching data", e.message);
console.error("Problem with fetching PRODUCT data", e.message);
console.error(e);
} finally {
loading.value = false;
}
Expand Down
10 changes: 7 additions & 3 deletions packages/default-theme/plugins/api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ export default ({ app, store }) => {
* Save current contextToken when its change
*/
onConfigChange(({ config }) => {
app.$cookies.set('sw-context-token', config.contextToken, {
maxAge: 60 * 60 * 24 * 365
})
try {
app.$cookies.set('sw-context-token', config.contextToken, {
maxAge: 60 * 60 * 24 * 365
})
} catch (e) {
// Sometimes cookie is set on server after request is send, it can fail silently
}
})

// Temporary fix for SSR and reactivity
Expand Down

1 comment on commit c61ee74

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for website ready!

Built with commit c61ee74

https://shopware-pwa-ml4ntq06r.now.sh

Please sign in to comment.