mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Updated types.
This commit is contained in:
parent
bdf2fa4f05
commit
366ef35d3d
14 changed files with 136 additions and 59 deletions
|
|
@ -11,24 +11,36 @@ const contentSecurityPolicy = [
|
|||
`connect-src 'self' api.umami.is`,
|
||||
];
|
||||
|
||||
const cspHeader = (values = []) => ({
|
||||
key: 'Content-Security-Policy',
|
||||
value: values
|
||||
.join(';')
|
||||
.replace(/\s{2,}/g, ' ')
|
||||
.trim(),
|
||||
});
|
||||
|
||||
const headers = [
|
||||
{
|
||||
key: 'X-DNS-Prefetch-Control',
|
||||
value: 'on',
|
||||
},
|
||||
!process.env.ALLOWED_FRAME_URLS && {
|
||||
{
|
||||
key: 'X-Frame-Options',
|
||||
value: 'SAMEORIGIN',
|
||||
},
|
||||
].filter(n => n);
|
||||
cspHeader(contentSecurityPolicy),
|
||||
];
|
||||
|
||||
const cspHeader = (values = []) => ({
|
||||
key: 'Content-Security-Policy',
|
||||
value: [...contentSecurityPolicy, ...values]
|
||||
.join(';')
|
||||
.replace(/\s{2,}/g, ' ')
|
||||
.trim(),
|
||||
});
|
||||
const shareHeaders = [
|
||||
{
|
||||
key: 'X-DNS-Prefetch-Control',
|
||||
value: 'on',
|
||||
},
|
||||
cspHeader([
|
||||
...contentSecurityPolicy,
|
||||
`frame-ancestors 'self' ${process.env.ALLOWED_FRAME_URLS || ''}`,
|
||||
]),
|
||||
];
|
||||
|
||||
if (process.env.FORCE_SSL) {
|
||||
headers.push({
|
||||
|
|
@ -127,14 +139,11 @@ const config = {
|
|||
return [
|
||||
{
|
||||
source: '/:path*',
|
||||
headers: [
|
||||
...headers,
|
||||
cspHeader([`frame-ancestors 'self' ${process.env.ALLOWED_FRAME_URLS || ''}`]),
|
||||
],
|
||||
headers,
|
||||
},
|
||||
{
|
||||
source: '/share/:path*',
|
||||
headers: [...headers, cspHeader()],
|
||||
headers: shareHeaders,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue