Useful if your app have or need an authentication system. It will simply parse cookies from all HTTP requests and made them available in your application. Cookies are a good system to share auth tokens between your server side and client side.
export default {
plugins: [
[
'@uvue/server/plugins/cookie',
{
secret: '',
options: {},
},
],
],
};
More information here: https://github.com/expressjs/cookie-parser
Can apply a GZIP compression on your files. Useful with you want to save bandwith in production mode.
export default {
plugins: [
[
'@uvue/server/plugins/gzip',
{
filter: null,
level: -1,
//...
},
],
],
};
More informations here: https://www.npmjs.com/package/compression
This plugin is required for your application to work properly: its purpose is to serve static files (js, css, images...) bundled or not by Webpack.
export default {
plugins: [
[
'@uvue/server/plugins/static',
{
acceptRanges: null,
index: false,
//...
},
],
],
};
More informations here: https://www.npmjs.com/package/serve-static
This plugin will display an error page in case of server error. In development mode, Youch is used to display error. In production mode a simple page is displayed and you can customize it: just indicate a path to a HTML file in the plugin configuration:
export default {
plugins: [
[
'@uvue/server/plugins/serverError',
{
path: path.join(__dirname, 'my-custom-error-page.html'), // This path need to be absolute
},
],
],
};
Simple plugin to handle modern and legacy bundles. You just have to install it and the plugin do all the job !
export default {
plugins: ['@uvue/server/plugins/modernMode'],
};
A plugin is just an object with defined methods to act on different hooks:
export default {
// Act on server bootstrap: good place to define some server middlewares
// and use methods from current used HTTP framework
install(app, options) {
app.use('/path', myMiddleware(options));
},
// Do an action before page will be rendered by Vue SSR
async beforeRender(context, app) {
// ...
},
// Body is rendered, now building the entire HTML page
async beforeBuild(response, context, app) {
// ...
},
// HTML is ready to be sent to client
async rendered(response, context, app) {
// You can alter response content before sending it
},
// Act when something go wrong during SSR rendering
async routeError(error, response, context, app) {
// Good place to render an error page
},
// Page was sent to client
afterResponse(context, app) {
// Good place to log things
},
};
Please take a look to UVue server plugins already done
← UVue