fix: csp nonce#2054
Draft
thibaultleouay wants to merge 1 commit into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Contributor
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/status-page/src/proxy.ts">
<violation number="1" location="apps/status-page/src/proxy.ts:156">
P1: The nullish-coalescing and ternary expression is grouped incorrectly, causing valid `redirect` values to be ignored.</violation>
<violation number="2" location="apps/status-page/src/proxy.ts:196">
P1: Rewrites set the CSP nonce in the response but do not forward the `x-nonce` request header, so rewritten routes can miss the nonce value needed by server components.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| // Preserve search params from original request | ||
| rewriteUrl.search = url.search; | ||
| return NextResponse.rewrite(rewriteUrl); | ||
| return withCsp(NextResponse.rewrite(rewriteUrl)); |
Contributor
There was a problem hiding this comment.
P1: Rewrites set the CSP nonce in the response but do not forward the x-nonce request header, so rewritten routes can miss the nonce value needed by server components.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/status-page/src/proxy.ts, line 196:
<comment>Rewrites set the CSP nonce in the response but do not forward the `x-nonce` request header, so rewritten routes can miss the nonce value needed by server components.</comment>
<file context>
@@ -159,7 +193,7 @@ export default auth(async (req) => {
// Preserve search params from original request
rewriteUrl.search = url.search;
- return NextResponse.rewrite(rewriteUrl);
+ return withCsp(NextResponse.rewrite(rewriteUrl));
}
</file context>
| NextResponse.redirect( | ||
| new URL( | ||
| `${req.nextUrl.origin}${ | ||
| redirect ?? type === "pathname" ? `/${prefix}` : "/" |
Contributor
There was a problem hiding this comment.
P1: The nullish-coalescing and ternary expression is grouped incorrectly, causing valid redirect values to be ignored.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/status-page/src/proxy.ts, line 156:
<comment>The nullish-coalescing and ternary expression is grouped incorrectly, causing valid `redirect` values to be ignored.</comment>
<file context>
@@ -114,14 +146,16 @@ export default auth(async (req) => {
+ NextResponse.redirect(
+ new URL(
+ `${req.nextUrl.origin}${
+ redirect ?? type === "pathname" ? `/${prefix}` : "/"
+ }`,
+ ),
</file context>
Suggested change
| redirect ?? type === "pathname" ? `/${prefix}` : "/" | |
| redirect ?? (type === "pathname" ? `/${prefix}` : "/") |
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.
No description provided.