Creates additional routing details for the root url of your project.
Using npm
npm install --save strapi-middleware-nextjs next react react-dom
Using yarn
yarn add strapi-middleware-nextjs next react react-dom
For Strapi stable versions, add a middleware.js
file within your config folder
e.g
touch config/middleware.js
module.exports = {
settings: {
public: {
defaultIndex: false
}
},
};
and in your root directory create a pages
folder
touch pages/index.js
Paste inside index.js
function HomePage() {
return <div>Welcome to Next.js!</div>
}
export default HomePage
strapi build
strapi run
"enabled": boolean, // Enable or disable the middle ware based on config
"overripeApiRoutes": boolean, // Enable or disable the api route adjustment [default:"/api/{route}"), false:"/{route}" ]
"enableProd": boolean, // Enable NextJS middleware in production environment