forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
50 lines (48 loc) · 1.82 KB
/
Copy pathnext.config.js
File metadata and controls
50 lines (48 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Self-hosted Grafana behind admin.omi.me/grafana (Cloud Run, us-central1).
const GRAFANA_ORIGIN =
process.env.GRAFANA_ORIGIN ?? 'https://omi-grafana-208440318997.us-central1.run.app';
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
// Pin the file-tracing root to this app dir. Next 15+ otherwise infers the
// workspace root from sibling lockfiles (monorepo) and nests the standalone
// output under that path, which breaks the Dockerfile's
// `COPY .next/standalone ./` + `CMD ["node","server.js"]`.
outputFileTracingRoot: __dirname,
images: { unoptimized: true },
async redirects() {
return [
// Analytics moved to be the default Dashboard. Keep old bookmarks alive.
{ source: '/dashboard/analytics', destination: '/dashboard', permanent: false },
];
},
async rewrites() {
// /dashboard embeds the self-hosted Grafana (Cloud Run) same-origin.
// Grafana serves itself under the /grafana sub-path (serve_from_sub_path).
return [
{ source: '/grafana', destination: `${GRAFANA_ORIGIN}/grafana` },
{ source: '/grafana/:path*', destination: `${GRAFANA_ORIGIN}/grafana/:path*` },
];
},
async headers() {
// Prevent clickjacking: disallow embedding any page (incl. /login) in a frame.
// Exception: the proxied Grafana may be framed by the dashboard page itself.
return [
{
source: '/(.*)?',
headers: [
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'Content-Security-Policy', value: "frame-ancestors 'none'" },
],
},
{
source: '/grafana/:path*',
headers: [
{ key: 'X-Frame-Options', value: 'SAMEORIGIN' },
{ key: 'Content-Security-Policy', value: "frame-ancestors 'self'" },
],
},
];
},
};
module.exports = nextConfig;