Skip to content

Commit b9c1110

Browse files
author
bapelin
committed
feat: support csp nonce
1 parent 038648a commit b9c1110

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/wrapper/src/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ export const createWrapper = <S extends Store>(makeStore: MakeStore<S>, config:
112112
const nextDataScript = document.getElementById(NEXT_DATA_SCRIPT_ID);
113113
const ssrData = JSON.parse(nextDataScript?.innerHTML || '{}');
114114
const ssrDataInitialState = ssrData?.props?.initialState || {};
115+
116+
if (config.nonce) {
117+
nextDataScript?.setAttribute('nonce', config.nonce);
118+
}
119+
115120
if (config.debug) {
116121
console.log(`ssr error, get next data initital state`, ssrDataInitialState);
117122
}
@@ -326,6 +331,7 @@ export interface Config<S extends Store> {
326331
serializeState?: (state: ReturnType<S['getState']>) => any;
327332
deserializeState?: (state: any) => ReturnType<S['getState']>;
328333
debug?: boolean;
334+
nonce?: string;
329335
}
330336

331337
export interface WrapperProps {

0 commit comments

Comments
 (0)