Commit 7a1031f4d3dbd2c1cf4ca8a0054447b2e88c2e3b
1 parent
c15bd7d4
chore: add "VITE_CONTENT_SECURITY_POLICY" configure feild to usage switch http or https protocol
Showing
5 changed files
with
11 additions
and
2 deletions
| ... | ... | @@ -10,7 +10,7 @@ import pkg from '../../../package.json'; |
| 10 | 10 | import { GLOB_CONFIG_FILE_NAME } from '../../constant'; |
| 11 | 11 | |
| 12 | 12 | export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { |
| 13 | - const { VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH } = env; | |
| 13 | + const { VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH, VITE_CONTENT_SECURITY_POLICY } = env; | |
| 14 | 14 | |
| 15 | 15 | const path = VITE_PUBLIC_PATH.endsWith('/') ? VITE_PUBLIC_PATH : `${VITE_PUBLIC_PATH}/`; |
| 16 | 16 | |
| ... | ... | @@ -24,6 +24,9 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { |
| 24 | 24 | // Inject data into ejs template |
| 25 | 25 | injectData: { |
| 26 | 26 | title: VITE_GLOB_APP_TITLE, |
| 27 | + contentSecurityPolicy: VITE_CONTENT_SECURITY_POLICY | |
| 28 | + ? `<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />` | |
| 29 | + : '', | |
| 27 | 30 | }, |
| 28 | 31 | // Embed the generated app.config.js file |
| 29 | 32 | tags: isBuild | ... | ... |
| 1 | 1 | <!DOCTYPE html> |
| 2 | 2 | <html lang="en" id="htmlRoot"> |
| 3 | 3 | <head> |
| 4 | - <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> | |
| 4 | + <%- contentSecurityPolicy %> | |
| 5 | 5 | <meta charset="UTF-8" /> |
| 6 | 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> |
| 7 | 7 | <meta name="renderer" content="webkit" /> | ... | ... |