-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
244 lines (238 loc) · 7.64 KB
/
Copy pathnext.config.ts
File metadata and controls
244 lines (238 loc) · 7.64 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import { withPostHogConfig } from "@posthog/nextjs-config";
import type { NextConfig } from "next";
// Where the /progress out-of-home ad URL sends people. GA4 reads utm_* off the
// landing URL and files the visit under this campaign in its acquisition
// reports; change the values here and both /progress rules follow.
const OOH_DESTINATION =
"/?utm_source=ooh&utm_medium=offline&utm_campaign=progress";
const nextConfig: NextConfig = {
async headers() {
return [
{
source: "/:path*",
headers: [
// Signals AI crawlers that training, search indexing, and agentic
// use are all permitted (https://contentsignals.org). Set here
// rather than public/_headers because the Docker deploy doesn't
// read that file.
{
key: "Content-Signal",
value: "ai-train=yes, search=yes, ai-input=yes",
},
],
},
];
},
async redirects() {
return [
{
source: "/great-canadian-builders",
destination: "/builders",
permanent: true,
},
{
source: "/great-canadian-builders/:slug",
destination: "/builders/:slug",
permanent: true,
},
// Both prior names of the State of the Nation dashboard redirect
// straight to the current route (no chained hops).
{
source: "/economic-indicators",
destination: "/state-of-the-nation",
permanent: true,
},
{
source: "/economic-indicators/:path*",
destination: "/state-of-the-nation/:path*",
permanent: true,
},
{
source: "/prosperity-dashboard",
destination: "/state-of-the-nation",
permanent: true,
},
{
source: "/prosperity-dashboard/:path*",
destination: "/state-of-the-nation/:path*",
permanent: true,
},
// /progress is the vanity URL printed on an out-of-home ad — not a page.
// It carries campaign parameters to the homepage so GA4 attributes the
// visit to the ad; without them a bare redirect to / is invisible,
// indistinguishable from organic homepage traffic. Trailing slash
// included because skipTrailingSlashRedirect is on, so "/progress/"
// won't normalize itself.
//
// Temporary on purpose: a 308 would sit in a visitor's browser and skip
// the server on later visits, so repeat scans would go uncounted.
{
source: "/progress",
destination: OOH_DESTINATION,
permanent: false,
},
{
source: "/progress/",
destination: OOH_DESTINATION,
permanent: false,
},
// Election coverage lives under /vote: the index at /vote, and Toronto's
// pages at /toronto/vote/<year>. Two earlier shapes are still out in the
// world — Toronto's /toronto/elections/2026 (indexed, and the target of
// shared pledge links) and Brampton's /elections/brampton/2026 — so both
// redirect. Each points straight at its final destination; none of these
// chain through another redirect.
{
source: "/elections",
destination: "/vote",
permanent: true,
},
// Only Toronto's coverage is live. Brampton, Hamilton and Ottawa are
// built but switched off (registry `hidden`), so every URL under them —
// including the old /elections shapes — lands on the /vote index rather
// than a page we aren't standing behind. These come first so they win
// over the Toronto-shaped rules below; none of them chain.
{
source: "/:city(brampton|hamilton|ottawa)/vote/:path*",
destination: "/vote",
permanent: false,
},
{
source: "/:city(brampton|hamilton|ottawa)/vote",
destination: "/vote",
permanent: false,
},
{
source: "/:city(brampton|hamilton|ottawa)/elections/:path*",
destination: "/vote",
permanent: false,
},
{
source: "/:city(brampton|hamilton|ottawa)/elections",
destination: "/vote",
permanent: false,
},
{
source: "/elections/brampton/2026/:path*",
destination: "/vote",
permanent: false,
},
{
source: "/elections/brampton/2026",
destination: "/vote",
permanent: false,
},
// Toronto's get-involved page is switched off. It stays in the repo but
// sends people to the election landing instead. The legacy /elections
// shape gets its own rule so it lands there directly rather than
// chaining through the generic /toronto/elections/:path* rule below.
{
source: "/toronto/vote/get-involved",
destination: "/toronto/vote/2026",
permanent: false,
},
{
source: "/toronto/elections/get-involved",
destination: "/toronto/vote/2026",
permanent: false,
},
{
source: "/toronto/elections",
destination: "/toronto/vote",
permanent: true,
},
{
source: "/toronto/elections/:path*",
destination: "/toronto/vote/:path*",
permanent: true,
},
];
},
async rewrites() {
const trackerBase = process.env.TRACKER_API_BASE;
// Default (buildcanada.com): Rails API is mounted under /tracker, paths
// pass through unchanged. Standalone host (e.g. nelson deploy): commitments
// and departments live at the root (strip /tracker/api/v1), while
// dashboard/burndown stay under /api (strip /tracker only). Mirrors the
// server-side mapping in src/lib/tracker-api.ts.
const trackerRewrites = trackerBase
? [
{
source: "/tracker/api/v1/:path*",
destination: `${trackerBase}/:path*`,
},
{
source: "/tracker/api/:path*",
destination: `${trackerBase}/api/:path*`,
},
]
: [
{
source: "/tracker/api/:path*",
destination: `https://www.buildcanada.com/tracker/api/:path*`,
},
];
return [
{
source: "/ph/static/:path*",
destination: "https://us-assets.i.posthog.com/static/:path*",
},
{
source: "/ph/:path*",
destination: "https://us.i.posthog.com/:path*",
},
{
source: "/ph/decide",
destination: "https://us.i.posthog.com/decide",
},
...trackerRewrites,
];
},
// Required to support PostHog trailing slash API requests
skipTrailingSlashRedirect: true,
images: {
unoptimized: process.env.NODE_ENV === "development",
remotePatterns: [
{
protocol: "https",
hostname: "cdn.prod.website-files.com",
},
{
protocol: "https",
hostname: "p16-sign-sg.tiktokcdn.com",
},
{
protocol: "https",
hostname: "storage.googleapis.com",
},
{
protocol: "https",
hostname: "images.lumacdn.com",
},
{
protocol: "https",
hostname: "york-factory.eng.canadasbuilding.com",
},
{
protocol: "https",
hostname: "yorkfactory.buildcanada.com",
},
{
protocol: "http",
hostname: "localhost",
},
],
},
};
const posthogApiKey = process.env.POSTHOG_API_KEY;
const posthogProjectId = process.env.POSTHOG_PROJECT_ID;
export default withPostHogConfig(nextConfig, {
personalApiKey: posthogApiKey ?? "",
projectId: posthogProjectId,
sourcemaps: {
// Keep builds working in local development and deployments where source
// map upload credentials have not been configured yet.
enabled: Boolean(posthogApiKey && posthogProjectId),
deleteAfterUpload: true,
},
});