Solved a weird bug
This commit is contained in:
@@ -16,8 +16,6 @@ export default function RootLayout({children}: {children: React.ReactNode}) {
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
<link rel="icon" href="/favicon.ico" sizes="any" />
|
||||||
<meta httpEquiv="Content-Security-Policy" content="default-src 'self' *.stripe.com" />
|
|
||||||
|
|
||||||
<script async src="https://js.stripe.com/v3/pricing-table.js" />
|
<script async src="https://js.stripe.com/v3/pricing-table.js" />
|
||||||
</head>
|
</head>
|
||||||
<body className={inter.className}>{children}</body>
|
<body className={inter.className}>{children}</body>
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
import {NextRequest, NextResponse} from "next/server";
|
|
||||||
|
|
||||||
export function middleware(request: NextRequest) {
|
|
||||||
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
|
|
||||||
const cspHeader = `
|
|
||||||
default-src 'self' *.stripe.com;
|
|
||||||
script-src 'self' 'nonce-${nonce}' *.stripe.com;
|
|
||||||
style-src 'self' 'nonce-${nonce}' *.stripe.com;
|
|
||||||
img-src 'self' blob: data: *.stripe.com;
|
|
||||||
font-src 'self' *.stripe.com;
|
|
||||||
object-src 'none' *.stripe.com;
|
|
||||||
base-uri 'self' *.stripe.com;
|
|
||||||
form-action 'self' *.stripe.com;
|
|
||||||
frame-ancestors 'none' *.stripe.com;
|
|
||||||
block-all-mixed-content;
|
|
||||||
upgrade-insecure-requests;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const requestHeaders = new Headers(request.headers);
|
|
||||||
|
|
||||||
// Setting request headers
|
|
||||||
requestHeaders.set("x-nonce", nonce);
|
|
||||||
requestHeaders.set(
|
|
||||||
"Content-Security-Policy",
|
|
||||||
// Replace newline characters and spaces
|
|
||||||
cspHeader.replace(/\s{2,}/g, " ").trim(),
|
|
||||||
);
|
|
||||||
|
|
||||||
return NextResponse.next({
|
|
||||||
headers: requestHeaders,
|
|
||||||
request: {
|
|
||||||
headers: requestHeaders,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const config = {
|
|
||||||
matcher: [
|
|
||||||
/*
|
|
||||||
* Match all request paths except for the ones starting with:
|
|
||||||
* - api (API routes)
|
|
||||||
* - _next/static (static files)
|
|
||||||
* - _next/image (image optimization files)
|
|
||||||
* - favicon.ico (favicon file)
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
source: "/((?!api|_next/static|_next/image|favicon.ico).*)",
|
|
||||||
missing: [
|
|
||||||
{type: "header", key: "next-router-prefetch"},
|
|
||||||
{type: "header", key: "purpose", value: "prefetch"},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user