A [content security policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) (CSP) adds an important layer of security to your web app by helping to mitigate cross-site scripting and data injection attacks. It enforces what content is loaded in your app. This includes images, CSS, fonts, scripts, network requests, and more. This guide describes how you can set up and customize a CSP for your site. ## What you'll learn In this tutorial, you'll learn how to do the following tasks: - Setup a Content Security Policy on an existing Hydrogen app. - Define custom directives within your Content Security Policy. - Secure third party scripts with a Content Security Policy nonce. ## Requirements - You've completed the Hydrogen Getting Started with a Hello World example project. ## Step 1: Set up a content security policy Hydrogen provides a default content security policy. Add the content security policy by using the [`createContentSecurityPolicy` utility](/docs/api/hydrogen/utilities/createcontentsecuritypolicy) within your `entry.server.jsx` file which returns: - `nonce`: Pass this value to React's `renderToReadableStream` or any other custom component that renders a script under the hood. - `NonceProvider`: This makes the nonce available throughout the app, and renders it by wrapping `RemixServer`. - `header`: This is the actual content security policy header value. Add it to your app response headers. Your updated `entry.server.jsx` should look something like the following: