šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Book a DemoInstallSign in
Socket

@progfay/nextjs-ssg-rewrite-rule-gen

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@progfay/nextjs-ssg-rewrite-rule-gen

generate nginx rewrite rules for Next.js SSG (Pages Router)

1.1.0
latest
Source
npm
Version published
Weekly downloads
3.2K
9.01%
Maintainers
1
Weekly downloads
Ā 
Created
Source

@progfay/nextjs-ssg-rewrite-rule-gen

Description

Next.js supports Static Exports.

However, it's a lot of work to manage the routing for the generated file without Vercel. Dynamic Routes feature makes routing more difficult.

This application automatically generates nginx rewrite rules for generated files.

Requirements

Installation

npm install -D @progfay/nextjs-ssg-rewrite-rule-gen

Configuration

[!NOTE] This application is available with zero configuration.

You can run this application with config in following command: nextjs-ssg-rewrite-rule-gen --config config.json

{
	"pagesDirPath": "apps/src/pages",
	"ignoreRoutes": ["/debug"],
  "nginxConfigs": [
    {
      "pattern": "^/credential$",
      "directives": ["add_header Cache-Control \"no-store\";"]
    }
  ],
	"basePath": "/app",
	"trailingSlash": true
}

Available configs:

How to work

pages directory:

pages
└── user
    ā”œā”€ā”€ [id]
        └── index.js
    └── new
        └── index.js

↓

Generated files with Static Exports (next build and output: "export"):

out
└── user
    ā”œā”€ā”€ [id].html
    └── new.html

↓

nginx rewrite rules (generated by @progfay/nextjs-ssg-rewrite-rule-gen):

location ~ ^/user/new/?$ {
  rewrite ^/user/new/?$ /user/new.html break;
}

location ~ ^/user/[^/]+?/?$ {
  rewrite ^/user/[^/]+?/?$ /user/[id].html break;
}

FAQs

Package last updated on 17 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts