You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTTP module supports Nuxt 2. Nuxt 3 users can use the new isomorphic [$fetch API](https://nuxt.com/docs/getting-started/data-fetching#isomorphic-fetch-and-fetch) ([migration guide](https://nuxt.com/docs/migration/component-options#isomorphic-fetch)).
20
+
17
21
## Features
18
22
19
23
- The fluent [ky](https://github.com/sindresorhus/ky) API has been extended with enhancements and shortcuts
Copy file name to clipboardExpand all lines: docs/content/1.getting-started/1.setup.md
+12-18Lines changed: 12 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
-
---
2
-
title: Setup
3
-
description: 'How to setup your module'
1
+
# Setup
2
+
3
+
How to setup your module.
4
+
4
5
---
5
6
6
7
Checkout the [Nuxt documentation](https://nuxtjs.org/api/configuration-modules#the-modules-property) for more information about installing and using modules.
@@ -9,22 +10,15 @@ Checkout the [Nuxt documentation](https://nuxtjs.org/api/configuration-modules#t
9
10
10
11
Add `@nuxt/http` dependency to your project:
11
12
12
-
:::::code-group
13
-
::::code-block{label="Yarn"active}
14
-
15
-
```bash
13
+
::code-group
14
+
```bash [Yarn]
16
15
yarn add @nuxt/http
17
16
```
18
17
19
-
::::
20
-
::::code-block{label="NPM"}
21
-
22
-
```bash
18
+
```bash [NPM]
23
19
npm install @nuxt/http
24
20
```
25
-
26
-
::::
27
-
:::::
21
+
::
28
22
29
23
Then add it to the modules section in your `nuxt.config.js`:
30
24
@@ -34,9 +28,9 @@ export default {
34
28
}
35
29
```
36
30
37
-
:::alert{type="success"}
31
+
::alert{type="success"}
38
32
That's it! You can now use [$http](/usage) in your Nuxt app ✨
39
-
:::
33
+
::
40
34
41
35
## Configure
42
36
@@ -56,9 +50,9 @@ export default {
56
50
57
51
See [http's options](/API/options).
58
52
59
-
:::alert{type="warning"}
53
+
::alert{type="warning"}
60
54
Note that this module does not currently support IE 11 because of using [ky](https://github.com/sindresorhus/ky) ([open issue](https://github.com/nuxt/http/issues/126))
This method should probably not be called inside hooks as it is global and will apply to all future requests
58
-
:::
59
+
::
59
60
60
-
:::alert{type="info"}
61
+
::alert{type="info"}
61
62
Please note that HTTP headers are case-insensitive. Therefore all header names will be converted to lower-case to make sure that if you set the same header twice but with different casing the last one set will be used.
62
63
63
64
See also [this comment](https://github.com/sindresorhus/ky/issues/105#issuecomment-470169100) in the Ky repository for more information
Copy file name to clipboardExpand all lines: docs/content/1.index.md
+8-12Lines changed: 8 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,12 @@
1
-
---
2
-
title: Introduction
3
-
description: 'HTTP module for Nuxt.js provides a universal way to make HTTP requests to the API backend.'
4
-
---
1
+
# Introduction
5
2
6
-
:::alert{type="warning"}
7
-
HTTP module supports Nuxt 2. Nuxt 3 users can use the new isomorphic [$fetch API](https://v3.nuxtjs.org/getting-started/data-fetching#isomorphic-fetch-and-fetch) ([migration guide](https://v3.nuxtjs.org/docs/migration/component-options#isomorphic-fetch)).
8
-
:::
3
+
HTTP module for Nuxt.js provides a universal way to make HTTP requests to the API backend.
HTTP module supports Nuxt 2. Nuxt 3 users can use the new isomorphic [$fetch API](https://nuxt.com/docs/getting-started/data-fetching#isomorphic-fetch-and-fetch) ([migration guide](https://nuxt.com/docs/migration/component-options#isomorphic-fetch)).
9
+
::
14
10
15
11
The HTTP module for [Nuxt](https://nuxtjs.org) provides a universal way to make HTTP requests to any API.
16
12
@@ -22,15 +18,15 @@ Starting from [v2.5.0](https://github.com/nuxt/nuxt.js/releases/tag/v2.5.0), Nux
22
18
23
19
## Features
24
20
25
-
:::list
21
+
::list
26
22
27
23
- The fluent ky API has been extended with enhancements and shortcuts
28
24
- Highly customizable options support for `BaseURL`
29
25
- Automatically proxy cookies and headers when making requests from server side
30
26
- Best practices to avoid token sharing when making server side requests
31
27
- Easy proxy support to avoid CORS problems and making deployment easier
Copy file name to clipboardExpand all lines: docs/content/2.API/1.options.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
-
---
2
-
title: Options
3
-
description: 'You can pass options using module options or http section in nuxt.config.js'
4
-
---
1
+
# Options
5
2
6
-
You can pass options using module options or `http` section in `nuxt.config.js`
3
+
You can pass options using module options or `http` section in `nuxt.config.js`.
4
+
5
+
---
7
6
8
7
```js
9
8
{
@@ -33,9 +32,9 @@ Base URL which is used and prepended to make requests in server side.
33
32
34
33
Environment variable `API_URL` can be used to **override**`baseURL`.
35
34
36
-
:::alert{type="info"}
35
+
::alert{type="info"}
37
36
`baseURL` and `proxy` won't work together, you will need to use [`prefix`](/options#prefix) instead
38
-
:::
37
+
::
39
38
40
39
## `browserBaseURL`
41
40
@@ -82,11 +81,11 @@ You can easily integrate HTTP with [Proxy Module](https://github.com/nuxt-commun
82
81
}
83
82
```
84
83
85
-
:::alert{type="info"}
84
+
::alert{type="info"}
86
85
It is not required to manually register `@nuxtjs/proxy` module, but it does need to be in your dependencies
87
-
:::
86
+
::
88
87
89
-
:::alert{type="info"}
88
+
::alert{type="info"}
90
89
`/api/` will be added to all requests to the API end point. If you need to remove it use `pathRewrite`:
91
90
92
91
```js
@@ -97,7 +96,7 @@ proxy: {
97
96
}
98
97
}
99
98
```
100
-
:::
99
+
::
101
100
102
101
## `retry`
103
102
@@ -147,9 +146,9 @@ In SSR context, sets client request header as http default request headers.
147
146
This is useful for making requests which need cookie based auth on server side.
148
147
Also helps making consistent requests in both SSR and Client Side code.
149
148
150
-
:::alert{type="info"}
149
+
::alert{type="info"}
151
150
When directing requests at a url protected by CloudFlare's CDN you should set this to `false` to prevent CloudFlare from mistakenly detecting a reverse proxy loop and returning a 403 error.
152
-
:::
151
+
::
153
152
154
153
## `proxyHeadersIgnore`
155
154
@@ -163,10 +162,10 @@ Headers added to all requests. If provided, will be merged with the defaults.
163
162
164
163
* Default: `{}`
165
164
166
-
:::alert{type="info"}
165
+
::alert{type="info"}
167
166
Do NOT include any credentials or tokens here. One can easily access them.
168
-
:::
167
+
::
169
168
170
-
:::alert{type="info"}
169
+
::alert{type="info"}
171
170
This headers are effective to ALL requests. Please take care and consider providing special headers on each call that needs this unless you are pretty sure you always need to add headers.
Copy file name to clipboardExpand all lines: docs/content/2.API/2.runtime-config.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
-
---
2
-
title: Runtime Config
3
-
description: 'The use of runtime config is mandatory in case of using environment variables in production.'
1
+
# Runtime Config
2
+
3
+
The use of runtime config is mandatory in case of using environment variables in production.
4
+
4
5
---
5
6
6
7
The use of [runtime config](https://nuxtjs.org/guide/runtime-config) is mandatory in case of using environment variables in production. Otherwise, the values will be hard coded during build and won't change until the next build.
0 commit comments