gatsby-plugin-express
v1.1.6
Published
Express server redirects with Gatsby
Downloads
921
Maintainers
Readme
gatsby-plugin-express
Server side client route matching, redirect and 404 handling
Usage
gatsby-config.js
plugins: [
{
resolve: 'gatsby-plugin-express',
options: {
output: 'config/gatsby-express.json',
}
}
]
express app
const gatsyExpress = require('gatsby-plugin-express');
const app = express();
// serve static files before gatsbyExpress
app.use(express.static('public/'));
app.use(gatsyExpress('config/gatsby-express.json', {
publicDir: 'public/',
template: 'public/404/index.html',
// redirects all /path/ to /path
// should be used with gatsby-plugin-remove-trailing-slashes
redirectSlashes: true,
}));