Skip to content

Commit 992229e

Browse files
committed
feat: remove csp (and add ds_store to gitignore)
1 parent 3d99d2f commit 992229e

3 files changed

Lines changed: 1 addition & 32 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.env
22
/node_modules
3+
.DS_Store

frontend/src/app/layout.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Metadata } from "next";
22
import { Space_Grotesk } from "next/font/google";
3-
import { headers } from "next/headers";
43
import Script from "next/script";
54
import type React from "react";
65

@@ -99,8 +98,6 @@ export default async function RootLayout({
9998
children: React.ReactNode;
10099
}) {
101100
const user = await auth({ noThrow: true, type: "adonis" });
102-
const headersList = await headers();
103-
const nonce = headersList.get("x-nonce");
104101

105102
return (
106103
<html lang="pl" suppressHydrationWarning={true} className="scroll-smooth">
@@ -121,7 +118,6 @@ export default async function RootLayout({
121118
src="https://analytics.solvro.pl/script.js"
122119
data-website-id="ab126a0c-c0ab-401b-bf9d-da652aab69ec"
123120
data-domains="planer.solvro.pl"
124-
nonce={nonce ?? undefined}
125121
/>
126122
<Toaster richColors={true} />
127123
</body>

frontend/src/middleware.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,13 @@ import { NextResponse } from "next/server";
44
import { auth } from "./lib/auth";
55

66
export async function middleware(request: NextRequest) {
7-
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
8-
const cspHeader = `
9-
default-src 'self' 'nonce-${nonce}' https://fonts.googleapis.com https://fonts.gstatic.com https://analytics.solvro.pl ${process.env.NODE_ENV === "development" ? "http://localhost:3333" : ""};
10-
script-src 'self' 'nonce-${nonce}' 'strict-dynamic' ${process.env.NODE_ENV === "development" ? "'unsafe-eval'" : ""} https://analytics.solvro.pl;
11-
style-src 'self' 'unsafe-inline';
12-
img-src 'self' blob: data: https://avatars.githubusercontent.com https://wit.pwr.edu.pl https://cms.solvro.pl https://apps.usos.pwr.edu.pl;
13-
font-src 'self';
14-
object-src 'none';
15-
base-uri 'self';
16-
form-action 'self';
17-
frame-ancestors 'none';
18-
upgrade-insecure-requests;
19-
`;
20-
21-
const contentSecurityPolicyHeaderValue = cspHeader
22-
.replaceAll(/\s{2,}/g, " ")
23-
.trim();
24-
257
const requestHeaders = new Headers(request.headers);
26-
requestHeaders.set("x-nonce", nonce);
27-
28-
requestHeaders.set(
29-
"Content-Security-Policy",
30-
contentSecurityPolicyHeaderValue,
31-
);
328

339
const nextResponse = NextResponse.next({
3410
request: {
3511
headers: requestHeaders,
3612
},
3713
});
38-
nextResponse.headers.set(
39-
"Content-Security-Policy",
40-
contentSecurityPolicyHeaderValue,
41-
);
4214

4315
const payload = {
4416
adonisSession: request.cookies.get("adonis-session")?.value ?? "",

0 commit comments

Comments
 (0)