mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
fix(vue-renderer): add vary header for user-agent
in modern server mode (#5807)
This commit is contained in:
parent
a0958f03f4
commit
7e50fe744f
@ -109,4 +109,12 @@ export default class ModernRenderer extends SSRRenderer {
|
||||
return linkTag.replace('rel="preload"', `rel="modulepreload"${cors}`).replace(legacyJsFile, modernJsFile)
|
||||
})
|
||||
}
|
||||
|
||||
async render(renderContext) {
|
||||
const result = await super.render(renderContext)
|
||||
if (this.isServerMode) {
|
||||
renderContext.res.setHeader('Vary', 'User-Agent')
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,14 @@ describe('modern server mode', () => {
|
||||
].join(', '))
|
||||
})
|
||||
|
||||
test('Vary header should contain User-Agent', async () => {
|
||||
const { headers: { vary } } = await rp(url('/'), {
|
||||
resolveWithFullResponse: true,
|
||||
headers: { 'user-agent': modernUA }
|
||||
})
|
||||
expect(vary).toContain('User-Agent')
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
afterAll(async () => {
|
||||
await nuxt.close()
|
||||
|
Loading…
Reference in New Issue
Block a user