Skip to content

Commit

Permalink
fix(nuxt-module): skip reading private runtime config in csr (#1628)
Browse files Browse the repository at this point in the history
* fix(nuxt-module): skip reading private runtime config in csr

* chore: changeset
  • Loading branch information
mkucmus authored Jan 23, 2025
1 parent 62db0de commit a22588f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-rivers-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware/nuxt-module": patch
---

Read private shopware config only in SSR context.
8 changes: 4 additions & 4 deletions packages/nuxt-module/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default defineNuxtPlugin((NuxtApp) => {
runtimeConfig.public?.shopware?.shopwareEndpoint;

const shopwareEndpointSSR =
runtimeConfig.shopware?.endpoint ?? shopwareEndpointCSR;
(NuxtApp.ssrContext && runtimeConfig.shopware?.endpoint) ||
shopwareEndpointCSR;

const shopwareEndpoint = import.meta.server
? shopwareEndpointSSR
Expand Down Expand Up @@ -63,10 +64,9 @@ export default defineNuxtPlugin((NuxtApp) => {
contextToken: shouldUseSessionContextInServerRender
? contextTokenFromCookie
: "",
defaultHeaders: defu(
runtimeConfig.apiClientConfig?.headers,
defaultHeaders:
(NuxtApp.ssrContext && runtimeConfig.apiClientConfig?.headers) ||
runtimeConfig.public?.apiClientConfig?.headers,
),
});

apiClient.hook("onContextChanged", (newContextToken) => {
Expand Down

0 comments on commit a22588f

Please sign in to comment.