{"repo":"marek-e/next-armored","free":true,"listed":false,"github":"https://github.com/marek-e/next-armored","clone":"git clone https://github.com/marek-e/next-armored.git","description":"NextJs middleware toolkit to secure your next server with flexibility and ease. Default configurations are based on best practices and security standards.","language":"TypeScript","stars":21,"topics":["cors","csp","middleware","next","nextjs","security"],"license":"MIT","category":"security-tools","readme_excerpt":"Next-armored 🛡️ NextJs middleware toolkit to secure your next server with flexibility and ease. - 🚀 Easy to use: simple middleware creation. - 🔧 Flexible: Customize middleware configurations to fit your needs. - 🛡️ Secure: Default configurations are based on best practices and security standards. - ✅ Type-safe: Middleware is fully typed and compatible with Next and TypeScript. - 🌐 Open source: Audit, report issues, and contribute. Installation Package Manager Using npm: Using yarn: Using pnpm: Using bun: Usage CORS middleware See how to configure CORS middleware for more details. Go to your middleware.ts file and add the following code: Import the createCorsMiddleware function from next-armored/cors and pass the configuration object to it. You have to at least specify the origins option because keeping by default is not recommended as it can be a security risk. Then add the cors middleware to the middleware function and return the result. Last step is to export the config object which is used to match the middleware to your api routes. If you are building a public api, you can allow all origins by passing origins: [' '] to the createCorsMiddleware function. ⚠️ But be aware that this can be a security risk. How to combine with other middlewares The first option is to call the first middleware and get the response. Then you can give the response to the cors middleware as an argument. In this case, the cors middleware will attach the headers to the response instead of retur","default_branch":null,"files":null,"tree":[],"storefront":"/r/marek-e","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/marek-e/next-armored/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}