How to enable http2 protocol in nuxt.js app? I have added SSL certificates and enabled modern mode, played with render>http2 settings in nuxt.config.js, but no matter what I try app still serves request with standard http/1.1 protocol. I can't seem to find anything about it in the documentation either.
Here is my nuxt.config.js:
import path from 'path'
import fs from 'fs'
export default {
server: {
https: {
key: fs.readFileSync(path.resolve(__dirname, 'certs/localhost.key')),
cert: fs.readFileSync(path.resolve(__dirname, 'certs/localhost.crt'))
}
},
mode: 'universal',
modern: true,
render: {
http2: {
push: true, pushAssets: null
}
},
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{charset: 'utf-8'},
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
{hid: 'description', name: 'description', content: process.env.npm_package_description || ''}
],
link: [
{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}
]
},
/*
** Customize the progress-bar color
*/
loading: {color: '#fff'},
/*
** Global CSS
*/
css: [
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
// Doc: https://github.com/nuxt-community/nuxt-tailwindcss
'@nuxtjs/tailwindcss'
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/pwa',
// Doc: https://github.com/nuxt-community/dotenv-module
'@nuxtjs/dotenv'
],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
}
}
Thank in advance.
You should set your mode to modern:
mode: 'modern'
And specify in the render.http2.pushAssets the actual assets that should be pushed (you currently have null in your sample code).
For example:
export default {
// ...
render: {
http2: {
push: true,
pushAssets: [
'/css/main.css',
'/js/main.js'
]
}
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With