Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/security headers #4842

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
17 changes: 16 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,26 @@ const moduleExports = withBundleAnalyzer({
locales,
defaultLocale,
},
headers: () => {
headers: async () => {
kkatusic marked this conversation as resolved.
Show resolved Hide resolved
return [
{
source: '/:path*',
locale: false,
headers: [
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'Content-Security-Policy',
value: "frame-ancestors 'self'",
},
],
},
{
// Adding CORS headers for /manifest.json
source: '/manifest.json',
locale: false,
headers: [
{
key: 'Access-Control-Allow-Origin',
Expand Down
12 changes: 11 additions & 1 deletion src/components/views/verification/EmailVerificationIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,20 @@ export default function EmailVerificationIndex() {
}

function Verified() {
const [querySlug, setQuerySlug] = useState<string | undefined>(undefined);
const router = useRouter();
const { slug } = router.query;
const { formatMessage } = useIntl();

// we must wait for the router to be ready to get the slug from the query
useEffect(() => {
if (router.isReady) {
if (typeof slug === 'string') {
setQuerySlug(slug);
}
}
}, [router.isReady, slug]);

return (
<>
<Image
Expand All @@ -99,7 +109,7 @@ function Verified() {
})}
</Lead>
<LinkHolder>
<Link href={slugToVerification(slug as string)}>
<Link href={slugToVerification(querySlug as string)}>
<ButtonLink
size='small'
label={
Expand Down