mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
🐛 fix: add Content-Security-Policy env (#8752)
* fix: add Content-Security-Policy * feat: add env to control csp open or not * update env
This commit is contained in:
+22
-6
@@ -9,6 +9,7 @@ const buildWithDocker = process.env.DOCKER === 'true';
|
||||
const isDesktop = process.env.NEXT_PUBLIC_IS_DESKTOP_APP === '1';
|
||||
const enableReactScan = !!process.env.REACT_SCAN_MONITOR_API_KEY;
|
||||
const isUsePglite = process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite';
|
||||
const shouldUseCSP = process.env.ENABLED_CSP === '1';
|
||||
|
||||
// if you need to proxy the api endpoint to remote server
|
||||
|
||||
@@ -41,14 +42,29 @@ const nextConfig: NextConfig = {
|
||||
webVitalsAttribution: ['CLS', 'LCP'],
|
||||
},
|
||||
async headers() {
|
||||
const securityHeaders = [
|
||||
{
|
||||
key: 'x-robots-tag',
|
||||
value: 'all',
|
||||
},
|
||||
];
|
||||
|
||||
if (shouldUseCSP) {
|
||||
securityHeaders.push(
|
||||
{
|
||||
key: 'X-Frame-Options',
|
||||
value: 'DENY',
|
||||
},
|
||||
{
|
||||
key: 'Content-Security-Policy',
|
||||
value: "frame-ancestors 'none';",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
headers: [
|
||||
{
|
||||
key: 'x-robots-tag',
|
||||
value: 'all',
|
||||
},
|
||||
],
|
||||
headers: securityHeaders,
|
||||
source: '/:path*',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user