-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(useStyleTag): support passing nonce
#4749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
packages/core/useStyleTag/index.ts
Outdated
@@ -53,7 +53,7 @@ let _id = 0 | ||
*/ | ||
export function useStyleTag( | ||
css: MaybeRef<string>, | ||
options: UseStyleTagOptions = {}, | ||
options: UseStyleTagOptions & { nonce?: string } = {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add this here:
vueuse/packages/core/useScriptTag/index.ts
Lines 8 to 48 in 92d855e
export interface UseScriptTagOptions extends ConfigurableDocument { | |
/** | |
* Load the script immediately | |
* | |
* @default true | |
*/ | |
immediate?: boolean | |
/** | |
* Add `async` attribute to the script tag | |
* | |
* @default true | |
*/ | |
async?: boolean | |
/** | |
* Script type | |
* | |
* @default 'text/javascript' | |
*/ | |
type?: string | |
/** | |
* Manual controls the timing of loading and unloading | |
* | |
* @default false | |
*/ | |
manual?: boolean | |
crossOrigin?: 'anonymous' | 'use-credentials' | |
referrerPolicy?: 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url' | |
noModule?: boolean | |
defer?: boolean | |
/** | |
* Add custom attribute to the script tag | |
* | |
*/ | |
attrs?: Record<string, string> | |
} |
with proper docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will write the type in the location you mentioned.
nonce
Before submitting the PR, please make sure you do the following
fixes #123
).Description
#4741 Bypass the strict Content Security Policy (CSP) using nonce
// Example of CSP header
Content-Security-Policy: style-src 'self' 'nonce-EDNnf03nceIOfn39fn3e9h3sdfa';
// Pass in the nonce when using it
useStyleTag(css, {
nonce: 'EDNnf03nceIOfn39fn3e9h3sdfa'
})
Additional context