mirror of https://github.com/sundowndev/http.git
parent
b1fb704435
commit
7c13655ef4
|
@ -43,6 +43,7 @@
|
||||||
- [credentials](#credentials)
|
- [credentials](#credentials)
|
||||||
- [debug](#debug)
|
- [debug](#debug)
|
||||||
- [proxyHeaders](#proxyheaders)
|
- [proxyHeaders](#proxyheaders)
|
||||||
|
- [proxyHeadersIgnore](#proxyHeadersIgnore)
|
||||||
- [redirectError](#redirecterror)
|
- [redirectError](#redirecterror)
|
||||||
- [requestInterceptor](#requestinterceptor)
|
- [requestInterceptor](#requestinterceptor)
|
||||||
- [responseInterceptor](#responseinterceptor)
|
- [responseInterceptor](#responseinterceptor)
|
||||||
|
@ -162,6 +163,11 @@ Also helps making consistent requests in both SSR and Client Side code.
|
||||||
|
|
||||||
> **NOTE:** If 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.
|
> **NOTE:** If 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.
|
||||||
|
|
||||||
|
### `proxyHeadersIgnore`
|
||||||
|
- Default `['host', 'accept']`
|
||||||
|
|
||||||
|
Only efficient when `proxyHeaders` is set to true. Removes unwanted request headers to the API backend in SSR.
|
||||||
|
|
||||||
### `redirectError`
|
### `redirectError`
|
||||||
- Default: `{}`
|
- Default: `{}`
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ module.exports = function nuxtAxios (moduleOptions) {
|
||||||
browserBaseURL: null,
|
browserBaseURL: null,
|
||||||
credentials: true,
|
credentials: true,
|
||||||
proxyHeaders: true,
|
proxyHeaders: true,
|
||||||
|
proxyHeadersIgnore: ['accept', 'host'],
|
||||||
debug: false,
|
debug: false,
|
||||||
redirectError: {}
|
redirectError: {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,9 +122,8 @@ export default <% if (options.init) { %>async<% } %>(ctx, inject) => {
|
||||||
<% if(options.proxyHeaders) { %>
|
<% if(options.proxyHeaders) { %>
|
||||||
// Default headers
|
// Default headers
|
||||||
headers.common = (req && req.headers) ? Object.assign({}, req.headers) : {}
|
headers.common = (req && req.headers) ? Object.assign({}, req.headers) : {}
|
||||||
delete headers.common.host
|
<% for (let h of options.proxyHeadersIgnore) { %>delete headers.common['<%= h %>']
|
||||||
delete headers.common.accept
|
<% } %><% } %>
|
||||||
<% } %>
|
|
||||||
|
|
||||||
// Create new axios instance
|
// Create new axios instance
|
||||||
const axios = Axios.create({
|
const axios = Axios.create({
|
||||||
|
|
Loading…
Reference in New Issue