Skip to content

Commit 1e81491

Browse files
committed
Revert "fix: typos in docs"
This reverts commit cbfb905.
1 parent cbfb905 commit 1e81491

File tree

2 files changed

+58
-50
lines changed

2 files changed

+58
-50
lines changed

docs/content/1.getting-started/3.usage.md

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ title: Usage
33
description: Learn how to use headers and middleware both globally and per route.
44
---
55

6+
7+
68
Nuxt Security by default registers a set of **global** Nuxt `routeRules` that will make your application more secure by default. Both headers and middleware can be easily configured and even disabled when needed.
79

810
::callout{icon="i-heroicons-light-bulb"}
9-
Read more about security headers [here](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#use-appropriate-security-headers).
11+
Read more about security headers [here](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#use-appropriate-security-headers).
1012
::
1113

1214
## Global configuration
@@ -71,6 +73,7 @@ If your application defines conflicting headers at both levels, the `security` p
7173

7274
For more information on `routeRules` please see the [Nuxt documentation](https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering)
7375

76+
7477
## Runtime hooks
7578

7679
If you need to change the configuration at runtime, it is possible to do it through the `nuxt-security:routeRules` hook.
@@ -85,7 +88,7 @@ export default defineNitroPlugin((nitroApp) => {
8588
// You can fetch configuration data asynchronously from an external source
8689
const validDomain = await $fetch('https://some-site.com/rules')
8790
// You can then override the security options of any route
88-
routeRules['/some/route'] = {
91+
routeRules['/some/route'] = {
8992
headers: {
9093
contentSecurityPolicy: {
9194
"connect-src": ["'self'", validDomain]
@@ -108,54 +111,58 @@ Headers delivered on other resources (e.g. images, js and css files, api routes
108111

109112
Nuxt-Security applies your rules in the following prority order:
110113

114+
111115
1. Default rules
112116

113-
Nuxt-Security default values.
114-
See [here](/getting-started/configuration#default)
117+
Nuxt-Security default values.
118+
See [here](/getting-started/configuration#default)
119+
115120

116121
2. Inline module options
117122

118-
```ts{}[nuxt.config.ts]
119-
export default defineNuxtConfig({
120-
modules: [
121-
['nuxt-security', { /* Inline Options */ }]
122-
]
123-
})
124-
```
123+
```ts{}[nuxt.config.ts]
124+
export default defineNuxtConfig({
125+
modules: [
126+
['nuxt-security', { /* Inline Options */ }]
127+
]
128+
})
129+
```
130+
125131

126132
3. Global module options
127133

128-
```ts{}[nuxt.config.ts]
129-
export default defineNuxtConfig({
130-
security: {
131-
// Global Options
132-
}
133-
})
134-
```
134+
```ts{}[nuxt.config.ts]
135+
export default defineNuxtConfig({
136+
security: {
137+
// Global Options
138+
}
139+
})
140+
```
135141

136142
4. Per-route options
137143

138-
```ts{}[nuxt.config.ts]
139-
export default defineNuxtConfig({
140-
routeRules: {
141-
'/some-route': {
142-
security: {
143-
// Per-route Options
144+
```ts{}[nuxt.config.ts]
145+
export default defineNuxtConfig({
146+
routeRules: {
147+
'/some-route': {
148+
security: {
149+
// Per-route Options
150+
}
144151
}
145152
}
146-
}
147-
})
148-
```
153+
})
154+
```
149155

150156
5. Runtime-hook options
151157

152-
```ts{}[server/plugins/filename.ts]
153-
export default defineNitroPlugin((nitroApp) => {
154-
nitroApp.hooks.hook('nuxt-security:routeRules', routeRules => {
155-
// Runtime Options
158+
```ts{}[server/plugins/filename.ts]
159+
export default defineNitroPlugin((nitroApp) => {
160+
nitroApp.hooks.hook('nuxt-security:routeRules', routeRules => {
161+
// Runtime Options
162+
})
156163
})
157-
})
158-
```
164+
```
165+
159166

160167
## Route merging strategy (nested router)
161168

@@ -189,9 +196,10 @@ export default defineNuxtConfig({
189196
})
190197
```
191198

199+
192200
## Inline route configuration
193201

194-
You can also use route rules in pages like following:
202+
You can also use route roules in pages like following:
195203

196204
```vue
197205
<template>
@@ -206,8 +214,8 @@ defineRouteRules({
206214
},
207215
rateLimiter: {
208216
tokensPerInterval: 3,
209-
interval: 60000
210-
}
217+
interval: 60000,
218+
},
211219
}
212220
})
213221
</script>
@@ -252,6 +260,7 @@ export default defineNuxtConfig({
252260
})
253261
```
254262

263+
255264
## Modifying security options
256265

257266
Within your runtime hooks, you can either modify or overwrite the existing values for any security option.
@@ -266,7 +275,7 @@ One of the easiest way to merge existing rules with your own is to use `defuRepl
266275
export default defineNitroPlugin((nitroApp) => {
267276
nitroApp.hooks.hook('nuxt-security:routeRules', async(routeRules) => {
268277
routeRules['/some/route'] = defuReplaceArray(
269-
{
278+
{
270279
headers: {
271280
contentSecurityPolicy: {
272281
"script-src": ["'self'", "..."]
@@ -280,9 +289,8 @@ export default defineNitroPlugin((nitroApp) => {
280289
})
281290
```
282291

283-
In the example above,
284-
285-
- All existing security options for `/some/route` will be maintained, and only the `script-src` CSP directive will be modified.
292+
In the example above,
293+
- All existing security options for `/some/route` will be maintained, and only the `script-src` CSP directive will be modified.
286294
- The existing content of the `script-src` directive will be erased and replaced by your values
287295

288296
Read more about [`defuReplaceArray`](/advanced/auto-imports/#defuReplaceArray)
@@ -301,7 +309,7 @@ import { defu } from 'defu'
301309
export default defineNitroPlugin((nitroApp) => {
302310
nitroApp.hooks.hook('nuxt-security:routeRules', async(routeRules) => {
303311
routeRules['/some/route'] = defu(
304-
{
312+
{
305313
headers: {
306314
contentSecurityPolicy: {
307315
"script-src": ["'self'", "..."]
@@ -315,21 +323,21 @@ export default defineNitroPlugin((nitroApp) => {
315323
})
316324
```
317325

318-
In the example above,
319-
320-
- All existing security options for `/some/route` will be maintained, and only the `script-src` CSP directive will be modified.
326+
In the example above,
327+
- All existing security options for `/some/route` will be maintained, and only the `script-src` CSP directive will be modified.
321328
- The existing content of the `script-src` directive will be preserved, and your values will be added to the existing values.
322329

323330
Read more about [`defu`](https://github.com/unjs/defu)
324331

332+
325333
### Overwriting rules
326334

327335
If you want to erase the existing settings, don't use defu and overwrite the values:
328336

329337
```ts{}[server/plugins/filename.ts]
330338
export default defineNitroPlugin((nitroApp) => {
331339
nitroApp.hooks.hook('nuxt-security:routeRules', async(routeRules) => {
332-
routeRules['/some/route'] = {
340+
routeRules['/some/route'] = {
333341
headers: {
334342
contentSecurityPolicy: {
335343
"script-src": ["'self'", "..."]
@@ -341,7 +349,7 @@ export default defineNitroPlugin((nitroApp) => {
341349
})
342350
```
343351

344-
In the example above,
345-
346-
- All existing security options for `/some/route` will be erased.
352+
In the example above,
353+
- All existing security options for `/some/route` will be erased.
347354
- The `script-src` directive will contain your values.
355+

docs/content/3.middleware/4.cors-handler.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: CORS Handler
3-
description: Set rules for Cross Origin Resource Sharing.
3+
description: Set roules for Cross Origin Resource Sharing.
44
links:
55
- label: Enabled
66
icon: i-heroicons-check-badge
@@ -11,7 +11,7 @@ links:
1111
This middleware will help you set your CORS options and it is based on built in [H3 CORS](https://github.com/unjs/h3) functionality
1212

1313
::callout{icon="i-heroicons-light-bulb"}
14-
Read more about Cross Origin Resource Sharing [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
14+
Read more about Cross Origin Resource Sharing [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
1515
::
1616

1717
Testing CORS configuration can be done by running one application with NuxtSecurity enabled and creating a second application (that is running on a different port) that will send a request to the first app. Then, a CORS error could be easily observed that proves that CORS is working as expected.

0 commit comments

Comments
 (0)