-
-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathnext.config.js
More file actions
85 lines (81 loc) · 2.62 KB
/
Copy pathnext.config.js
File metadata and controls
85 lines (81 loc) · 2.62 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
const i18Config = require("./next-i18next.config")
const config = {
/** typesense-instantsearch-adapter 3.x ships ESM syntax in .js files whose
* package main is not marked "type": "module", so Next's default server
* externalization require()s it and node fails on its extensionless relative
* imports — 500ing every search page. Transpiling bundles it instead.
*/
transpilePackages: ["typesense-instantsearch-adapter"],
images: {
loader: "custom"
},
compiler: {
styledComponents: true
},
eslint: {
dirs: ["pages", "components", "functions/src", "tests", "analysis"]
},
i18n: i18Config.i18n
}
/** @type {import('next').NextConfig} */
module.exports = {
...config,
async redirects() {
return [
redirectFirebaseAuthHandlers(),
// Three of the four old Learn testimony tabs were consolidated into
// /learn/testimony. These slugs were linked from the footer and from
// external sites, so they redirect permanently rather than 404. Each tab
// became a section of the new page and keeps its old slug as an anchor id
// (see ANCHORS in components/learn/Testimony/AboutTestimony.tsx), so the
// reader lands on the content that replaced the page they asked for
// rather than at the top. "testimony-basics" was the overview tab, which
// the whole page now covers, so it has no anchor.
...[
"testimony-basics",
"role-of-testimony",
"communicating-with-legislators"
].map(slug => ({
source: `/learn/${slug}`,
destination:
slug === "testimony-basics"
? "/learn/testimony"
: `/learn/testimony#${slug}`,
permanent: true
}))
]
},
async rewrites() {
const rewrites = [
{
source: "/policies",
destination: "/policies/privacy-policy"
}
]
if (process.env.MCP_PROXY_URL) {
rewrites.push({
source: "/api/mcp/:path*",
destination: `${process.env.MCP_PROXY_URL}/:path*`
})
}
return rewrites
}
}
/**
* Redirect auth handler paths to the hosted firebase pages. This avoids having
* to implement these pages ourselves in next.js but continues to depend on
* firebase hosting a bit.
*b
* In production, FIREBASE_AUTH_DOMAIN is set to digital-testimony-prod.web.app.
*
* @see https://firebase.google.com/docs/auth/custom-email-handler
*/
const redirectFirebaseAuthHandlers = () => {
const firebaseDomain =
process.env.FIREBASE_AUTH_DOMAIN ?? "digital-testimony-dev.web.app"
return {
source: "/__/:path*",
destination: `https://${firebaseDomain}/__/:path*`,
permanent: false
}
}