@nosecone/next
v1.0.0-alpha.30
Published
Protect your Next.js application with secure headers
Downloads
158
Readme
@nosecone/next
Protect your Next.js application with secure headers.
Installation
npm install -S @nosecone/next
Example
Create a middleware.ts
file with the contents:
import { createMiddleware } from "@nosecone/next";
export const config = {
// matcher tells Next.js to run middleware on all routes
matcher: ["/(.*)"],
};
export default createMiddleware();
Add await connection()
in your app/layout.tsx
file:
+ import { connection } from "next/server";
export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
+ // Opt-out of static generation for every page so the CSP nonce can be applied
+ await connection()
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
);
}
License
Licensed under the Apache License, Version 2.0.