You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`"'nonce-{{nonce}}'"` placeholder: Include this value in any individual policy that you want to be governed by nonce.
216
216
217
217
218
-
::alert{type="warning"}
219
-
Our default recommendation is to avoid using the `"'nonce-{{nonce}}'"` placeholder on `style-src` policy.
220
-
<br>
221
-
⚠ This is because Nuxt's mechanism for Client-Side hydration of styles could be blocked by CSP in that case.
222
-
<br>
223
-
For further discussion and alternatives, please refer to our [Advanced Section on Strict CSP](/documentation/advanced/strict-csp).
224
-
::
225
-
226
-
227
218
_Note: Nonce only works for SSR. The `nonce` option and the `"'nonce-{{nonce}}'"` placeholders are ignored when you build your app for SSG via `nuxi generate`._
228
219
229
220
@@ -304,28 +295,6 @@ Please see below our section on [Integrity Hashes For SSG](#integrity-hashes-for
304
295
_Note: Hashes only work for SSG. The `ssg` options are ignored when you build your app for SSR via `nuxi build`._
305
296
306
297
307
-
308
-
## Hot reload during development
309
-
310
-
If you have enabled `nonce-{{nonce}}` on `style-src`, you will need to disable it in order to allow hot reloading during development.
The Access-Control-Allow-Origin response header indicates whether the response can be shared with requesting code from the given origin.
69
+
The Access-Control-Allow-Origin response header indicates whether the response can be shared with requesting code from the given origin. Use `'*'` to allow all origins. You can pass a single origin, or a list of origins.
70
+
71
+
### `useRegExp`
72
+
73
+
Set to `true` to parse all origin values into a regular expression using `new RegExp(origin, 'i')`.
74
+
You cannot use RegExp instances directly as origin values, because the nuxt config needs to be serializable.
75
+
When using regular expressions, make sure to escape dots in origins correctly. Otherwise a dot will match every character.
76
+
77
+
The following matches `https://1.foo.example.com`, `https://a.b.c.foo.example.com`, but not `https://foo.example.com`.
@@ -324,24 +324,24 @@ The `useScript` method has several key features:
324
324
- It does not insert inline event handlers, therefore CSP will never block the script from executing after load
325
325
- It is designed to load and execute asynchronously, which means you don't have to write code to check whether the script has finished loading before using it
326
326
327
-
For all of these reasons, we strongly recommend `useScript` as the best way to load your external scripts in a CSP-compatible way.
327
+
In addition, Nuxt Scripts provide easy integration of `useScript` into any Nuxt application:
328
+
- A number of standard scripts are already pre-packaged
329
+
- You can load your scripts globally in `nuxt.config.ts`
330
+
- `useScript` is auto-imported
328
331
329
-
The `unjs/unhead` repo has a [detailed section here](https://unhead.unjs.io/usage/composables/use-script) on how to use `useScript`.
332
+
For all of these reasons, we strongly recommend using the Nuxt Scripts module as the best way to load your external scripts in a CSP-compatible way.
330
333
331
-
Check out their examples and find out how easy it is to include Google Analytics in your application:
334
+
Check out their examples on [@nuxt/scripts](https://scripts.nuxt.com) and find out how easy it is to include Google Analytics in your application:
// Now use any feature of Google's gtag() function as you wish
342
341
// Instead of writing complex code to find and check window.gtag
343
342
```
344
343
344
+
If you don't want to install the Nuxt Scripts module, you can still use the uderlying native `useScript` method. You will need to `import { useScript } from'@unhead/vue'` in order to use it.
0 commit comments