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