1.2.0 • Published 2 years ago
nx-nginx-routes v1.2.0
next-nginx-routes
Generate Nginx routes configuration file for Next.js static HMTL export.
This NPM package allows you to convert Next.js routes like:
{
"page": "/[foo]",
"regex": "^/([^/]+?)(?:/)?$",
"routeKeys": { "foo": "foo" },
"namedRegex": "^/(?<foo>[^/]+?)(?:/)?$"
}... into Nginx routes like:
location ~ ^/([^/]+?)(?:/)?$ {
try_files /[foo].html /index.html;
}Getting started
Installation
yarn add --dev next-nginx-routesGenerate Nginx configuration file
Add next-nginx-routes to your export script:
{
"export": "next build && next export && next-nginx-routes"
}And run Next.js export:
yarn run exportInclude Nginx configuration file
Finally include the generated configuration file next-routes.conf and the Next.js output in your Nginx site configuration file.
Requirements
More
1.2.0
2 years ago