Skip to content

Commit

Permalink
adding react-helmet for csp
Browse files Browse the repository at this point in the history
  • Loading branch information
mgtennant committed May 1, 2024
1 parent b842ff7 commit 8179c35
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
25 changes: 25 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react-bootstrap": "^2.10.1",
"react-datepicker": "^6.6.0",
"react-dom": "^18.2.0",
"react-helmet-async": "^2.0.4",
"react-loading-skeleton": "^3.4.0",
"react-redux": "^9.0.4",
"react-router-dom": "^6.22.1",
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/app/content/pages/ManageTemplatesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DocType } from '../../types/types';
import UploadTemplateModal from '../../components/modal/manage-templates/UploadTemplateModal';
import RemoveTemplateModal from '../../components/modal/manage-templates/RemoveTemplateModal';
import { getDocumentTypes } from '../../common/report';
import { Helmet } from 'react-helmet-async';

const ManageTemplatesPage: FC = () => {
const [showUploadModal, setShowUploadModal] = useState<boolean>(false);
Expand Down Expand Up @@ -50,6 +51,14 @@ const ManageTemplatesPage: FC = () => {

return (
<>
<Helmet>
<meta
httpEquiv="Content-Security-Policy"
content={`
frame-src https://*.gov.bc.ca blob:;
`}
></meta>
</Helmet>
<h1>Manage Templates</h1>
<hr />
<div className="col-md-3">
Expand All @@ -61,7 +70,8 @@ const ManageTemplatesPage: FC = () => {
id="reportTypes"
style={{ minWidth: '200px' }}
className="border border-1 rounded pl-2 ml-4"
onChange={selectedDocTypeHandler}>
onChange={selectedDocTypeHandler}
>
{allDocTypes.map((docType) => (
<option key={docType.id} value={docType.id}>
{docType.name}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import App from './app/App';
import './app/App.css';
import reportWebVitals from './reportWebVitals';
import UserService from './app/service/user-service';
import { HelmetProvider } from 'react-helmet-async';

const container = document.getElementById('root')!;
const root = createRoot(container);

const onAuthenticatedCallback = () =>
root.render(
<StrictMode>
<App />
<HelmetProvider>
<App />
</HelmetProvider>
</StrictMode>
);

Expand Down

0 comments on commit 8179c35

Please sign in to comment.