Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-suits-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"io-services-cms-backoffice": patch
---

only track csp violations
4 changes: 2 additions & 2 deletions apps/backoffice/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const nextConfig = {
source: "/((?!api|_next/static|_next/image|favicon.ico).*)",
headers: [
{
key: "Content-Security-Policy",
key: "Content-Security-Policy-Report-Only",
value:
"default-src 'self'; img-src https://iopstcdnassets.blob.core.windows.net https://selfcare.pagopa.it"
"report-to /csp-reports default-src 'self'; frame-src 'none'; object-src 'none'; img-src https://iopstcdnassets.blob.core.windows.net https://selfcare.pagopa.it"
}
]
}
Expand Down
18 changes: 18 additions & 0 deletions apps/backoffice/src/app/api/csp-reports/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NextRequest, NextResponse } from "next/server";
import * as ai from "applicationinsights";

export async function POST(
nextRequest: NextRequest,
nextResponse: NextResponse
) {
const jsonBody = await nextRequest.json();

ai.defaultClient.trackException({
exception: new Error(JSON.stringify(jsonBody)),
severity: ai.Contracts.SeverityLevel.Warning
});

return new Response("Success!", {
status: 200
});
}