Skip to content

Commit b62fb0e

Browse files
committed
docs: properly mention how to use the runtime config (#107)
1 parent 3b182a1 commit b62fb0e

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

docs/content/1.setup/2.configuration.md

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,13 @@ export default defineNuxtConfig({
2525
| `clients.[client].query` | `SearchParameters` | | Adds query search params to URL |
2626
| `clients.[client].schema` | `OpenAPI3Schema` | | Local or remote schema file (YAML or JSON) |
2727

28-
Client can also be configured using `runtimeConfig` or environment variables:
28+
## Runtime configuration
29+
30+
All base URLs are available at runtime under `public.openFetch.[client].baseURL`.\
31+
You can access and modify them using `useRuntimeConfig()`.
32+
33+
You can use this to override url based on environment variables.
2934

30-
```ts twoslash [nuxt.config.ts]
31-
// @noErrors
32-
export default defineNuxtConfig({
33-
openFetch: {
34-
clients: {
35-
pets: {} // The key should be specified as it is used to generate the client
36-
}
37-
},
38-
runtimeConfig: {
39-
public: {
40-
openFetch: {
41-
pets: {
42-
schema: 'https://petstore3.swagger.io/api/v3/openapi.json',
43-
baseURL: 'https://petstore3.swagger.io/api/v3/'
44-
},
45-
},
46-
}
47-
},
48-
})
49-
```
50-
or:
5135
```dotenv [.env]
52-
NUXT_PUBLIC_OPEN_FETCH_PETS_SCHEMA=https://petstore3.swagger.io/api/v3/openapi.json
53-
NUXT_PUBLIC_OPEN_FETCH_PETS_BASE_URL=https://petstore3.swagger.io/api/v3/
36+
NUXT_PUBLIC_OPEN_FETCH_PTES_BASE_URL=https://petstore3.swagger.io/api/v3/
5437
```

0 commit comments

Comments
 (0)