Arcjet Nosecone: Security headers for JS frameworks
Arcjet Nosecone is an open source library
that helps set security headers such as Content-Security-Policy (CSP),
Strict-Transport-Security (HSTS), and X-Content-Type-Options in JS
applications built with Bun, Deno, Next.js, Node.js, or SvelteKit.
What are Arcjet utilities?
Arcjet utilities are independent libraries
that do not require the use of the main Arcjet SDK—they can be used with or
without other Arcjet rules.
We take the pain out of implementing security tasks through these utilities
to provide a security as code approach to developer-first security.
Supported headers
Nosecone makes it easy to add and configure these headers:
This guide will show you how to add our recommended
default security headers.
1. Install Nosecone
In your project root, run the following command to install the Arcjet Nosecone
library for your framework:
2. Configure your application
Nosecone creates headers that can be used directly as the Response headers in
your Deno server.
Nosecone creates headers that can be used directly as the Response headers in
your Bun server.
Nosecone applies headers to all your routes via middleware in your Next.js
application.
We recommend you remove any export const config = ... from your middleware so
Nosecone will run on every route. This ensures the headers are applied to all
requests.
You also need to opt-out of static generation in your application. See the
@nosecone/nextreference
guide for more details
about this requirement.
To opt-out of static generation, modify your layout file with the following:
We recommend you remove any export const config = ... from your middleware so
Nosecone will run on every route. This ensures the headers are applied to all
requests.
Nosecone applies headers to all your routes via hooks in your SvelteKit
application.
Create the src/hooks.server.ts file in your project with the contents:
Create the src/hooks.server.js file in your project with the contents:
SvelteKit provides the Content-Security-Policy header via the framework, so
Nosecone helps you to configure it.
Update your svelte.config.js to configure csp:
Nosecone creates headers that can be applied directly with res.setHeaders() in
your Node.js server.
3. Run your application
4. Inspect the headers
The default headers apply a pragmatic set of security headers to your
application, but may break things (particularly the CSP header).
We recommend you test your application thoroughly and tweak the settings to
ensure it continues to work as expected.
Using the the curl command, we can inspect the headers:
The printed headers should look something like:
Using the the curl command, we can inspect the headers:
The printed headers should look something like:
Using the the curl command, we can inspect the headers:
The printed headers should look something like:
Using the the curl command, we can inspect the headers:
The printed headers should look something like:
Using the the curl command, we can inspect the headers:
The printed headers should look something like:
What next?
Nosecone referenceDetails about each security header and how to configure them.