File tree Expand file tree Collapse file tree 3 files changed +39
-19
lines changed Expand file tree Collapse file tree 3 files changed +39
-19
lines changed Original file line number Diff line number Diff line change @@ -168,10 +168,6 @@ export default (ctx, inject) => {
168
168
patch : { }
169
169
}
170
170
171
- if ( process . server ) {
172
- headers . common [ 'Accept-Encoding' ] = 'gzip, deflate'
173
- }
174
-
175
171
const axiosOptions = {
176
172
baseURL ,
177
173
headers
@@ -183,6 +179,11 @@ export default (ctx, inject) => {
183
179
< % for ( let h of options . proxyHeadersIgnore ) { % > delete axiosOptions . headers . common [ '<%= h %>' ]
184
180
< % } % > < % } % >
185
181
182
+ if ( process . server ) {
183
+ // Don't accept brotli encoding because Node can't parse it
184
+ axiosOptions . headers . common [ 'Accept-Encoding' ] = 'gzip, deflate'
185
+ }
186
+
186
187
// Create new axios instance
187
188
const axios = Axios . create ( axiosOptions )
188
189
Original file line number Diff line number Diff line change @@ -76,4 +76,17 @@ describe('axios module', () => {
76
76
expect ( d ) . not . toBeNull ( )
77
77
expect ( b ) . not . toBe ( d )
78
78
} )
79
+
80
+ test ( 'ssr no brotli' , async ( ) => {
81
+ const makeReq = login =>
82
+ axios
83
+ . get ( url ( '/ssr' + ( login ? '?login' : '' ) ) )
84
+ . then ( r => r . data )
85
+ . then ( h => / e n c o d i n g - \$ ( .* ) \$ / . exec ( h ) )
86
+ . then ( m => ( m && m [ 1 ] ? m [ 1 ] : null ) )
87
+
88
+ const result = await makeReq ( )
89
+
90
+ expect ( result ) . toBe ( 'gzip, deflate' )
91
+ } )
79
92
} )
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div >session-{{ axiosSessionId }}</div >
2
+ <div >
3
+ <div >session-{{ axiosSessionId }}</div >
4
+ <div >encoding-${{ axiosEncoding }}$</div >
5
+ </div >
3
6
</template >
4
7
5
8
<script >
6
- // This will be intentially shared across requests
7
- let reqCtr = 1
9
+ // This will be intentically shared across requests
10
+ let reqCtr = 1
8
11
9
- export default {
10
- async fetch ({ app, route }) {
11
- let doLogin = route .query .login !== undefined
12
- if (doLogin) {
13
- app .$axios .setHeader (' sessionId' , reqCtr++ )
14
- }
15
- },
16
- computed: {
17
- axiosSessionId () {
18
- return this .$axios .defaults .headers .common .sessionId
12
+ export default {
13
+ async fetch ({app, route}) {
14
+ let doLogin = route .query .login !== undefined
15
+ if (doLogin) {
16
+ app .$axios .setHeader (' sessionId' , reqCtr++ )
17
+ }
18
+ },
19
+ computed: {
20
+ axiosSessionId () {
21
+ return this .$axios .defaults .headers .common .sessionId
22
+ },
23
+ axiosEncoding () {
24
+ return this .$axios .defaults .headers .common [' Accept-Encoding' ]
25
+ }
19
26
}
20
27
}
21
- }
22
- </script >
28
+ </script >
You can’t perform that action at this time.
0 commit comments