Implement security hardening module#68
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new enterprise security hardening feature for Next.js projects generated by the CLI. The main changes add an automated security setup step, which generates secure environment variable validation, security headers, and other best practices during project creation. It also removes previously hardcoded environment validation from the template, centralizing this logic in the generator.
Security hardening automation:
applySecurityfunction insrc/security.jsthat, when enabled, automatically generates anenv.mjsfile with Zod-based environment variable validation, a.env.exampletemplate, a securenext.config.jswith recommended security headers, a.gitignorewith best practices, and ensureszodis added as a dependency. This step only applies to Next.js architectures and is invoked during project generation. [1] [2] [3]Template simplification:
env.mjsand related environment validation logic from the Next.js template (templates/portfolio/nextjs-monolith/env.mjsandlib/db.ts), so this logic is now provided by the generator when security hardening is enabled. [1] [2]Closes #47