diff --git a/next.config.js b/next.config.js
index cf7dce7f..03c30c55 100644
--- a/next.config.js
+++ b/next.config.js
@@ -3,29 +3,32 @@ require('dotenv').config();
const path = require('path');
const pkg = require('./package.json');
-const contentSecurityPolicy = `
- default-src 'self';
- img-src *;
- script-src 'self' 'unsafe-eval' 'unsafe-inline';
- style-src 'self' 'unsafe-inline';
- connect-src 'self' api.umami.is;
- frame-ancestors 'self' ${process.env.ALLOWED_FRAME_URLS};
-`;
+const contentSecurityPolicy = [
+ `default-src 'self'`,
+ `img-src *`,
+ `script-src 'self' 'unsafe-eval' 'unsafe-inline'`,
+ `style-src 'self' 'unsafe-inline'`,
+ `connect-src 'self' api.umami.is`,
+];
const headers = [
{
key: 'X-DNS-Prefetch-Control',
value: 'on',
},
- {
+ !process.env.ALLOWED_FRAME_URLS && {
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
- {
- key: 'Content-Security-Policy',
- value: contentSecurityPolicy.replace(/\s{2,}/g, ' ').trim(),
- },
-];
+].filter(n => n);
+
+const cspHeader = (values = []) => ({
+ key: 'Content-Security-Policy',
+ value: [...contentSecurityPolicy, ...values]
+ .join(';')
+ .replace(/\s{2,}/g, ' ')
+ .trim(),
+});
if (process.env.FORCE_SSL) {
headers.push({
@@ -81,14 +84,13 @@ const config = {
reactStrictMode: false,
env: {
basePath: basePath || '',
- cloudMode: !!process.env.CLOUD_MODE,
- cloudUrl: process.env.CLOUD_URL,
+ cloudMode: process.env.CLOUD_MODE || '',
+ cloudUrl: process.env.CLOUD_URL || '',
configUrl: '/config',
currentVersion: pkg.version,
- defaultLocale: process.env.DEFAULT_LOCALE,
- disableLogin: process.env.DISABLE_LOGIN,
- disableUI: process.env.DISABLE_UI,
- isProduction: process.env.NODE_ENV === 'production',
+ defaultLocale: process.env.DEFAULT_LOCALE || '',
+ disableLogin: process.env.DISABLE_LOGIN || '',
+ disableUI: process.env.DISABLE_UI || '',
},
basePath,
output: 'standalone',
@@ -125,7 +127,14 @@ const config = {
return [
{
source: '/:path*',
- headers,
+ headers: [
+ ...headers,
+ cspHeader([`frame-ancestors 'self' ${process.env.ALLOWED_FRAME_URLS || ''}`]),
+ ],
+ },
+ {
+ source: '/share/:path*',
+ headers: [...headers, cspHeader()],
},
];
},
diff --git a/src/app/(main)/Shell.tsx b/src/app/(main)/App.tsx
similarity index 90%
rename from src/app/(main)/Shell.tsx
rename to src/app/(main)/App.tsx
index 980abb62..daf98fb1 100644
--- a/src/app/(main)/Shell.tsx
+++ b/src/app/(main)/App.tsx
@@ -4,7 +4,7 @@ import { usePathname } from 'next/navigation';
import UpdateNotice from 'components/common/UpdateNotice';
import { useRequireLogin, useConfig } from 'components/hooks';
-export function Shell({ children }) {
+export function App({ children }) {
const { user } = useRequireLogin();
const config = useConfig();
const pathname = usePathname();
@@ -24,4 +24,4 @@ export function Shell({ children }) {
);
}
-export default Shell;
+export default App;
diff --git a/src/app/(main)/dashboard/page.tsx b/src/app/(main)/dashboard/page.tsx
index 91cc9c6e..1853a9f5 100644
--- a/src/app/(main)/dashboard/page.tsx
+++ b/src/app/(main)/dashboard/page.tsx
@@ -1,7 +1,7 @@
import Dashboard from 'app/(main)/dashboard/Dashboard';
import { Metadata } from 'next';
-export default function DashboardPage() {
+export default function () {
return