Skip to content

Commit e77dc8d

Browse files
committed
docs: update README
1 parent 964eca9 commit e77dc8d

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

packages/next-safe-middleware/README.md

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,11 @@ You can quickly edit, test and run on StackBlitz or deploy to Vercel from there.
6464
Create a file `pages/_middleware.(js|ts)`:
6565

6666
```js
67-
import { chain, nextSafe, provideHashesOrNonce } from '@next-safe/middleware';
67+
import { chain, nextSafe, strictDynamic } from '@next-safe/middleware';
6868

6969
const isDev = process.env.NODE_ENV === 'development';
7070

71-
const nextSafeWithStrictDynamic = nextSafe((req) => {
72-
// can't use strict-dynamic with `next dev`
73-
// Browser support of strict-dynamic: https://caniuse.com/?search=strict-dynamic
74-
// https://web.dev/strict-csp/#step-4:-add-fallbacks-to-support-safari-and-older-browsers
75-
const strictDynamic =
76-
!isDev
77-
? {
78-
'script-src': [`'strict-dynamic'`, 'https:', `'unsafe-inline'`],
79-
}
80-
: {};
81-
return {
82-
isDev,
83-
contentSecurityPolicy: {
84-
...strictDynamic,
85-
}
86-
// customize as you need: https://trezy.gitbook.io/next-safe/usage/configuration
87-
};
88-
});
89-
90-
export default chain(nextSafeWithStrictDynamic, provideHashesOrNonce);
71+
export default chain(nextSafe({ isDev }), strictDynamic());
9172
```
9273

9374
Then, create a custom `pages/_document.(jsx|tsx)`:
@@ -104,7 +85,7 @@ export default class MyDocument extends Document {
10485
}
10586

10687
render() {
107-
// those components are automagically wired with provideHashesOrNonce
88+
// those components are automagically wired with strictDynamic
10889
const { Head, NextScript } = provideComponents(this.props);
10990
return (
11091
<Html>
@@ -274,8 +255,6 @@ const geoBlockMiddleware = (req, evt, res, next) => {
274255
}
275256
```
276257

277-
This gives you IntelliSense for parameters, but not on return type. Make sure it is `Response | void`.
278-
279258
This will work when you have TypeScript enabled in your Next project. To do that, create an empty `tsconfig.json` file in the root of your Next project and run:
280259

281260
```

0 commit comments

Comments
 (0)