Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
98 lines (95 loc) · 4.23 KB
/
Copy pathnext.config.ts
File metadata and controls
98 lines (95 loc) · 4.23 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { withSentryConfig } from '@sentry/nextjs/config';
import path from 'path';
import type { NextConfig } from 'next';
import { noindexHeaders } from './src/lib/crawl.ts';
const nextConfig: NextConfig = {
// Self-contained server bundle for the Cloud Run image (deploy/Dockerfile).
output: 'standalone',
devIndicators: false,
// The Cloud SQL connector (db/connection.ts, instrumentation.ts) is
// Node-only, so this opts it out of Server Components bundling to a
// native `require`, which as a side effect makes the standalone
// output's dependency trace (deploy/Dockerfile's image) copy it into
// .next/standalone/node_modules.
serverExternalPackages: ['@google-cloud/cloud-sql-connector'],
// Phones/tablets on the LAN may open the dev server by the machine's IP
// (DEV_ORIGINS, comma-separated, e.g. 192.168.1.20) — dev-only.
allowedDevOrigins: (process.env.DEV_ORIGINS ?? '')
.split(',')
.map((origin) => origin.trim())
.filter(Boolean),
// Share and embed links, the Studio, history and sign-in say noindex on
// every response, redirects and errors included (src/lib/crawl.ts).
// src/proxy.ts sends /data's.
async headers() {
return noindexHeaders();
},
// ONE's privacy policy covers this site, and its Terms and Conditions
// section sets the terms of use; /privacy and /terms are the addresses
// the MCP directory listings give for them. Temporary, so a later page of
// our own can take either path without browsers holding the old target.
async redirects() {
return [
{
source: '/privacy',
destination: 'https://www.one.org/info/privacy-policy/',
permanent: false,
},
{
source: '/terms',
destination:
'https://www.one.org/info/privacy-policy/#h-terms-and-conditions-nbsp',
permanent: false,
},
];
},
// A docs page's raw markdown sits beside it: /docs/<path>.md serves the
// same file the docs corpus was built from (src/app/docs-md).
async rewrites() {
return [
{ source: '/docs.md', destination: '/docs-md' },
{ source: '/docs/:path*.md', destination: '/docs-md/:path*' },
// The platform doors live under a version prefix: /api/v1/* is the
// address to publish and the one Cloudflare's rules match, and the
// unversioned path stays as an alias so nothing already written
// against it breaks. Only these four families move — the site's own
// endpoints (auth, events, share, …) are not a public API and keep
// sitting directly under /api.
{ source: '/api/search/:path*', destination: '/api/v1/search/:path*' },
{ source: '/api/datasets', destination: '/api/v1/datasets' },
{ source: '/api/datasets/:path*', destination: '/api/v1/datasets/:path*' },
{ source: '/api/graph/:path*', destination: '/api/v1/graph/:path*' },
{ source: '/api/studio/:path*', destination: '/api/v1/studio/:path*' },
];
},
images: {
disableStaticImages: true,
},
sassOptions: {
loadPaths: [path.join(__dirname, 'src/styles')],
},
turbopack: {
root: __dirname,
rules: {
// src/assets/masks/ is left out so a stylesheet url() there stays a
// hashed, immutable asset. Every other .svg imports as a component.
'*.svg': {
condition: { not: { path: /^src\/assets\/masks\// } },
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
};
// Sentry's build step: source maps go up when SENTRY_AUTH_TOKEN (+ org and
// project) is set at build time, otherwise the build just runs without them.
// Browser reports ride our own same-origin tunnel (src/app/api/monitoring),
// not the plugin's rewrite — see the route for why.
export default withSentryConfig(nextConfig, {
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
silent: !process.env.CI,
widenClientFileUpload: true,
disableLogger: true,
});