Skip to content

Commit

Permalink
Merge pull request #59 from ramangupta44/bug/promo-banner-rv-issue
Browse files Browse the repository at this point in the history
Added Headers
  • Loading branch information
ramangupta44 authored Oct 3, 2023
2 parents 48327c5 + 1b1f8ec commit 78c8c8c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/sxastarter/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const jssConfig = require('./src/temp/config');
const { getPublicUrl } = require('@sitecore-jss/sitecore-jss-nextjs/utils');
const plugins = require('./src/temp/next-config-plugins') || {};

const headerConfig = require('./project-configs/header');
const publicUrl = getPublicUrl();

/**
Expand Down Expand Up @@ -56,6 +56,8 @@ const nextConfig = {
},
];
},

...headerConfig,
};

module.exports = () => {
Expand Down
30 changes: 30 additions & 0 deletions src/sxastarter/project-configs/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const securityHeaders = [
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains; preload',
},
{
key: 'Content-Security-Policy',
value:
"default-src *; style-src 'self' 'unsafe-inline' 'unsafe-eval' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; frame-src 'self' *; object-src 'self' ; img-src 'self' data: https:; font-src 'self' data: * https://fonts.gstatic.com; connect-src 'self' *; media-src * data: https:; base-uri 'self';",
},
];

module.exports = {
async headers() {
return [
{
source: '/:path*',
headers: securityHeaders,
},
];
},
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import React from 'react';
import { PlainHTMLResuableTemplateProps } from 'lib/component-props/EspireTemplateProps/PageContent/PlainHTMLResuableTemplateProps';
import { withDatasourceCheck } from '@sitecore-jss/sitecore-jss-nextjs';
import { withDatasourceCheck, Text } from '@sitecore-jss/sitecore-jss-nextjs';
import { EditMode } from 'lib/component-props';

export const PlainHTMLResuable = (props: PlainHTMLResuableTemplateProps): JSX.Element => {
const editMode = EditMode();
return (
<div className={`plain-text-reusable ${props.params.styles}`}>
<div dangerouslySetInnerHTML={{ __html: props?.fields?.PlainHTML?.value }} />
</div>
<>
{editMode ? (
<Text field={props?.fields?.PlainHTML} />
) : (
<div className={`plain-text-reusable ${props.params.styles}`}>
<div dangerouslySetInnerHTML={{ __html: props?.fields?.PlainHTML?.value }} />
</div>
)}
</>
);
};

Expand Down

1 comment on commit 78c8c8c

@vercel
Copy link

@vercel vercel bot commented on 78c8c8c Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.