@shopware-pwa/nuxt3-module
Advanced tools
Comparing version 1.0.8 to 1.1.0
@@ -34,7 +34,14 @@ import * as _nuxt_schema from '@nuxt/schema'; | ||
} | ||
interface ApiClientConfig { | ||
headers?: { | ||
[key: string]: string; | ||
}; | ||
} | ||
interface RuntimeConfig { | ||
shopware?: Pick<ShopwareNuxtOptions, "endpoint" | "shopwareEndpoint" | "useUserContextInSSR">; | ||
apiClientConfig?: ApiClientConfig; | ||
} | ||
interface PublicRuntimeConfig { | ||
shopware: ShopwareNuxtOptions; | ||
apiClientConfig?: ApiClientConfig; | ||
} | ||
@@ -41,0 +48,0 @@ } |
{ | ||
"name": "@shopware-pwa/nuxt3-module", | ||
"version": "1.0.8", | ||
"version": "1.1.0", | ||
"description": "Nuxt 3 module for Shopware Frontends", | ||
@@ -37,15 +37,15 @@ "author": "Shopware", | ||
"dependencies": { | ||
"@nuxt/kit": "3.13.2", | ||
"@nuxt/kit": "3.14.1592", | ||
"defu": "6.1.4", | ||
"js-cookie": "3.0.5", | ||
"@shopware-pwa/composables-next": "1.4.2", | ||
"@shopware-pwa/helpers-next": "1.1.0", | ||
"@shopware/api-client": "1.1.2" | ||
"@shopware-pwa/composables-next": "1.5.0", | ||
"@shopware-pwa/helpers-next": "1.2.0", | ||
"@shopware/api-client": "1.2.0" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/schema": "3.13.2", | ||
"nuxt": "3.13.2", | ||
"@biomejs/biome": "1.8.3", | ||
"@nuxt/schema": "3.14.1592", | ||
"nuxt": "3.14.1592", | ||
"typescript": "5.6.3", | ||
"unbuild": "2.0.0", | ||
"eslint-config-shopware": "1.0.0", | ||
"tsconfig": "0.0.0" | ||
@@ -56,3 +56,4 @@ }, | ||
"dev": "unbuild --stub", | ||
"lint": "eslint plugin.ts src/**/*.ts* --fix --max-warnings=0 && pnpm run typecheck", | ||
"lint": "biome check .", | ||
"lint:fix": "biome check . --write && pnpm run typecheck", | ||
"typecheck": "tsc --noEmit", | ||
@@ -59,0 +60,0 @@ "test": "echo \"Warn: no test specified yet\"" |
@@ -0,13 +1,14 @@ | ||
import { isMaintenanceMode } from "@shopware-pwa/helpers-next"; | ||
import { createAPIClient } from "@shopware/api-client"; | ||
import { defu } from "defu"; | ||
import { getCookie } from "h3"; | ||
import Cookies from "js-cookie"; | ||
import { ref } from "vue"; | ||
import { | ||
createShopwareContext, | ||
defineNuxtPlugin, | ||
showError, | ||
useRuntimeConfig, | ||
useState, | ||
createShopwareContext, | ||
createError, | ||
} from "#imports"; | ||
import { ref } from "vue"; | ||
import Cookies from "js-cookie"; | ||
import { createAPIClient } from "@shopware/api-client"; | ||
import { getCookie } from "h3"; | ||
import { isMaintenanceMode } from "@shopware-pwa/helpers-next"; | ||
import type { ApiClient } from "#shopware"; | ||
@@ -55,3 +56,3 @@ | ||
const contextTokenFromCookie = !!NuxtApp.ssrContext | ||
const contextTokenFromCookie = NuxtApp.ssrContext | ||
? getCookie(NuxtApp.ssrContext?.event, "sw-context-token") | ||
@@ -66,2 +67,6 @@ : Cookies.get("sw-context-token"); | ||
: "", | ||
defaultHeaders: defu( | ||
runtimeConfig.apiClientConfig?.headers, | ||
runtimeConfig.public?.apiClientConfig?.headers, | ||
), | ||
}); | ||
@@ -82,3 +87,3 @@ | ||
if (error) { | ||
throw createError({ | ||
throw showError({ | ||
statusCode: 503, | ||
@@ -91,3 +96,2 @@ statusMessage: "MAINTENANCE_MODE", | ||
NuxtApp.vueApp.provide("apiClient", apiClient); | ||
// Shopware context | ||
@@ -94,0 +98,0 @@ const shopwareContext = createShopwareContext(NuxtApp.vueApp, { |
@@ -91,2 +91,28 @@ # shopware/frontends - nuxt3-module | ||
## API Default Headers | ||
You can use Nuxt config to set the default API call headers. | ||
More about Nuxt configuration can be found [HERE](https://nuxt.com/docs/getting-started/configuration). | ||
> **_NOTE:_** By default, the values in `runtimeConfig` are only available on the server-side. However, keys within `runtimeConfig.public` are also accessible on the client-side. [MORE](https://nuxt.com/docs/getting-started/configuration#environment-variables-and-private-tokens) | ||
```json | ||
{ | ||
"runtimeConfig": { | ||
"public": { | ||
"apiClientConfig": { | ||
"headers": { | ||
"global-heder-example": "global-header-example-value" | ||
} | ||
} | ||
}, | ||
"apiClientConfig": { | ||
"headers": { | ||
"ssr-heder-example": "ssr-header-example-value" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
## Links | ||
@@ -103,8 +129,15 @@ | ||
### Latest changes: 1.0.8 | ||
### Latest changes: 1.1.0 | ||
### Minor Changes | ||
- [#1442](https://github.com/shopware/frontends/pull/1442) [`9669d1b`](https://github.com/shopware/frontends/commit/9669d1b39fca71461a3641840632db171f2968ed) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Added possibility to use Nuxt config file for setting the API requests headers. Headers are added to each request SSR and CSR. | ||
### Patch Changes | ||
- Updated dependencies [[`938c4cf`](https://github.com/shopware/frontends/commit/938c4cfe6438f0e11a34f69bc7a183f10ba7f381)]: | ||
- @shopware/api-client@1.1.2 | ||
- @shopware-pwa/composables-next@1.4.2 | ||
- [#1514](https://github.com/shopware/frontends/pull/1514) [`05a4792`](https://github.com/shopware/frontends/commit/05a479240cac709e18f411a6276de359937341a6) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Replace `createError` with `showError` function in the `onResponseError` hook to redirect the user to the Nuxt error page. | ||
- Updated dependencies [[`a87bbcf`](https://github.com/shopware/frontends/commit/a87bbcfa3f5aa440265b1e8f0fc72a204863befc), [`2c337b5`](https://github.com/shopware/frontends/commit/2c337b5555495e5cc75f17f1c7f50cc25dfe7c1e), [`13c83be`](https://github.com/shopware/frontends/commit/13c83bec53a6aaba49941b9bf869629eadeb4515), [`13c83be`](https://github.com/shopware/frontends/commit/13c83bec53a6aaba49941b9bf869629eadeb4515), [`8ba9702`](https://github.com/shopware/frontends/commit/8ba9702657d1dc31cc653728788830fa38bb4992), [`a03a492`](https://github.com/shopware/frontends/commit/a03a492f18ebff84606e47f5239330454c9f3039)]: | ||
- @shopware/api-client@1.2.0 | ||
- @shopware-pwa/composables-next@1.5.0 | ||
- @shopware-pwa/helpers-next@1.2.0 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19131
216
142
29
406
+ Added@nuxt/kit@3.14.1592(transitive)
+ Added@nuxt/schema@3.14.1592(transitive)
+ Added@shopware-pwa/composables-next@1.5.0(transitive)
+ Added@shopware-pwa/helpers-next@1.2.0(transitive)
+ Added@shopware/api-client@1.2.0(transitive)
+ Addedc12@2.0.4(transitive)
+ Addedchokidar@4.0.3(transitive)
+ Addedignore@6.0.2(transitive)
+ Addedohash@2.0.4(transitive)
+ Addedreaddirp@4.1.2(transitive)
- Removed@nuxt/kit@3.13.2(transitive)
- Removed@nuxt/schema@3.13.2(transitive)
- Removed@shopware-pwa/composables-next@1.4.2(transitive)
- Removed@shopware-pwa/helpers-next@1.1.0(transitive)
- Removed@shopware/api-client@1.1.2(transitive)
- Removedanymatch@3.1.3(transitive)
- Removedbinary-extensions@2.3.0(transitive)
- Removedc12@1.11.2(transitive)
- Removedchokidar@3.6.0(transitive)
- Removedfsevents@2.3.3(transitive)
- Removedignore@5.3.2(transitive)
- Removedis-binary-path@2.1.0(transitive)
- Removedjiti@1.21.7(transitive)
- Removednormalize-path@3.0.0(transitive)
- Removedohash@1.1.4(transitive)
- Removedreaddirp@3.6.0(transitive)
Updated@nuxt/kit@3.14.1592
Updated@shopware/api-client@1.2.0