์ค๋ฅ1. ์นด์นด์ค SDK ์คํฌ๋ฆฝํธ ํ์ผ import ์คํจ
์ค๋ฅ2. ๊ตฌ๊ธ ์ ๋์ผ์ค ์คํฌ๋ฆฝํธ ํ์ผ import ์คํจ
Refused to load the script 'https://developers.kakao.com/sdk/js/kakao.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. result:1 Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. |
์ด์ : XSS๊ณต๊ฒฉ์ ๋ง๊ธฐ ์ํด ์ธ๋ถ javascriptํ์ผ import๋ฅผ ๋ง์๋์ ๋ณด์ ๊ธฐ๋ฅ
ํด๊ฒฐ ๊ณผ์
1. HTML์ ์ธ๋ถ ์คํฌ๋ฆฝํธ ํ์ฉ ๋ฉํํ๊ทธ ์ถ๊ฐ
2. ์นํฉ ๋ชจ๋ external ์ถ๊ฐ
3. ์น ํฉ ์ํธ๋ฆฌ์ ์ธ๋ถ ์คํฌ๋ฆฝํธ ์ฃผ์ ์ ๋ ฅ
4. sdk๋ฅผ ์ง์ ๋ค์ด ๋ฐ์, ๋ก์ปฌํ๊ฒฝ์์ ์นํฉ์ผ๋ก ๋ฒ๋ค๋ง --> ์ ๋์ผ์ค ์คํฌ๋ฆฝํธ๋ ๋ถ๊ฐ
5. helmet CSP์ค์ ์์
css, image๋ค์ ๋ฌธ์ ์์ด import๋์๋ค ์ด์ ๋ helmetCSP์ JS๋ง ๋ง์๋์๊ธฐ ๋๋ฌธ์ด๋ค.
์ด๋ ์คํฌ๋ฆฝํธ๋ฅผ ์ง์ ๋ค ์์ ๊ณ ๋ค์ ์ถ๊ฐํด์ผ ์ปจ์์ ์ค๋ฅ๊ฐ ์ฌ๋ผ์ง๋ค.
app.use(
helmet({
contentSecurityPolicy: false,
})
);
const contentSecurityPolicy = require("helmet-csp");
app.use(
contentSecurityPolicy({
directives: {
defaultSrc: ["'self'", "default.example"],
scriptSrc: ["'self'", "'unsafe-inline'"],
objectSrc: ["'none'"],
upgradeInsecureRequests: [],
},
reportOnly: false,
})
);
github.com/helmetjs/helmet/tree/main/middlewares/content-security-policy
helmetjs/helmet
Help secure Express apps with various HTTP headers - helmetjs/helmet
github.com
Express ์น์ฌ์ดํธ ๋ณด์ ๊ฐํํ๊ธฐ [Helmet, CSP]
Express๋ก ๋ง๋ค์ด์ง ์น ์ฌ์ดํธ์ ๋ณด์์ ๊ฐํํ๊ธฐ ์ํด Helmet ๋ฏธ๋ค์จ์ด๋ฅผ ์ฌ์ฉํฉ๋๋ค.
blog.uniony.me
helmet, helmet-csp์ฌ์ฉ๋ฐฉ๋ฒ, ์ค๋ฅ Refused to load the
ํ๊ฒฝ: express VUE์์ cdn์ผ๋ก ๋ฐ์์ค๋ ํฐํธ๋, ์ด๋ฏธ์ง, cssํ์ํ์ผ์ helmet์ ์ํํ ํ์ผ์ด๋ผ๊ณ ์ธ์์ ํ์ฌ ๋ง๋๋ค ๊ทธ๋์ ๋น๋ ํ ํ์ผ์ Express์์ ์คํ ์ํค๋ฉด์ ํ๋์ ์๋ฒ๋ฅผ ์ฌ์ฉํ๋ฉด์ he
crispypotato.tistory.com
'๐ Back > ๐งฉ Node.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐ๋ฒจ&์นํฉ] IE, Safari์์ Javascript๊ฐ ์๋ํ์ง ์์๋ ์ด์ (0) | 2021.05.18 |
---|---|
504 Gateway Timeout ์ค๋ฅ ๋ฐ์(Nginx) (0) | 2021.05.18 |
PM2: ๋ฐฐํฌ ํ ๋ฐฑ๊ทธ๋ผ์ด๋์์ ๊ณ์ ์คํ๋๊ฒ ํ๊ธฐ (0) | 2021.04.09 |
Babel, Webpack์ค๋ฅ ํด๊ฒฐ ๋ชจ์ (0) | 2021.04.01 |
์นํฉ MAP ํ์ผ: jsํ์ผ ์๋ํ๊ฒ ํ๊ธฐ (0) | 2021.03.23 |