Skip to content

Commit e7dbbd7

Browse files
Issueid #0000 added meta tag in index html file
1 parent b5710ef commit e7dbbd7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ import { BrowserRouter as Router } from "react-router-dom";
99
import { getCSP } from "./csp";
1010

1111
const injectCSP = () => {
12-
const cspContent = getCSP(process.env); // Pass environment variables
13-
const metaTag = document.createElement("meta");
14-
metaTag.httpEquiv = "Content-Security-Policy";
15-
metaTag.content = cspContent.trim();
16-
document.head.appendChild(metaTag);
12+
try {
13+
const cspContent = getCSP(process.env); // Pass environment variables
14+
const metaTag = document.createElement("meta");
15+
metaTag.httpEquiv = "Content-Security-Policy";
16+
metaTag.content = cspContent.trim();
17+
document.head.appendChild(metaTag);
18+
} catch (error) {
19+
console.error("Failed to inject CSP:", error);
20+
}
1721
};
1822

19-
setTimeout(() => {
20-
injectCSP();
21-
}, 0);
23+
injectCSP();
2224

2325
render(
2426
<React.StrictMode>

0 commit comments

Comments
 (0)