chore(nitro): add Nitro config with security headers and CI build#19
Merged
chore(nitro): add Nitro config with security headers and CI build#19
Conversation
Add nitro.config.ts configured for the Bun preset and compress public assets. Apply global routeRules that set security and privacy headers: X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Strict-Transport-Security, Permissions-Policy, and a restrictive Content-Security-Policy allowing only necessary Cloudflare Turnstile endpoints. These headers harden MIME sniffing, clickjacking, referrer leakage, mixed-content, and hardware access. Update CI workflow to run a final Build step (bun run build) after tests to verify the project can be built before deployment.
Greptile SummaryThis PR adds a Nitro configuration file with comprehensive security headers and updates the CI pipeline to include a build step. Key Changes:
Minor Improvements Suggested:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Developer
participant GitHub
participant CI
participant Nitro
participant Browser
Developer->>GitHub: Push commit to PR
GitHub->>CI: Trigger workflow
CI->>CI: Lint code
CI->>CI: Type check
CI->>CI: Run tests
CI->>CI: Build project (NEW)
Note over CI: Validates deployment readiness
CI-->>GitHub: Report status
Note over Nitro: Runtime behavior (after deployment)
Browser->>Nitro: HTTP Request
Nitro->>Nitro: Apply security headers
Note over Nitro: X-Content-Type-Options: nosniff<br/>X-Frame-Options: DENY<br/>Referrer-Policy<br/>HSTS<br/>Permissions-Policy<br/>CSP
Nitro->>Browser: Response + Headers
Note over Browser: Headers enforce security policies
|
Comment on lines
+36
to
+40
| "default-src 'self'", | ||
| "script-src 'self' 'unsafe-inline' https://challenges.cloudflare.com", | ||
| "connect-src 'self' https://challenges.cloudflare.com", | ||
| "frame-src 'self' https://challenges.cloudflare.com", | ||
| "style-src 'self' 'unsafe-inline'", |
There was a problem hiding this comment.
style: 'unsafe-inline' for script-src and style-src weakens CSP by allowing inline scripts/styles. Consider using nonces or hashes instead for better security.
Prompt To Fix With AI
This is a comment left during a code review.
Path: nitro.config.ts
Line: 36:40
Comment:
**style:** `'unsafe-inline'` for `script-src` and `style-src` weakens CSP by allowing inline scripts/styles. Consider using nonces or hashes instead for better security.
How can I resolve this? If you propose a fix, please make it concise.| import { defineNitroConfig } from "nitro/config"; | ||
|
|
||
| export default defineNitroConfig({ | ||
| // Optimize for Bun since you are using it |
There was a problem hiding this comment.
style: The Bun preset is already configured in vite.config.ts:16 via the Nitro Vite plugin. Consider removing this duplicate configuration to avoid conflicts.
Prompt To Fix With AI
This is a comment left during a code review.
Path: nitro.config.ts
Line: 4:4
Comment:
**style:** The Bun preset is already configured in `vite.config.ts:16` via the Nitro Vite plugin. Consider removing this duplicate configuration to avoid conflicts.
How can I resolve this? If you propose a fix, please make it concise.
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.
Add nitro.config.ts configured for the Bun preset and compress public
assets. Apply global routeRules that set security and privacy headers:
X-Content-Type-Options, X-Frame-Options, Referrer-Policy,
Strict-Transport-Security, Permissions-Policy, and a restrictive
Content-Security-Policy allowing only necessary Cloudflare Turnstile
endpoints. These headers harden MIME sniffing, clickjacking, referrer
leakage, mixed-content, and hardware access.
Update CI workflow to run a final Build step (bun run build) after tests
to verify the project can be built before deployment.