Skip to content

Commit 36cbf66

Browse files
authored
Add labs.quansight.com -> .org redirect (#413)
Redirect all hosts starting with `labs` on to labs.quansight.org. This should: - Work cleanly for `labs.quansight.com` - Not interfere with any normal function of the LLC site - Also allow testing of the Vercel preview domains - The Vercel preview domains have to start with `labs-`, so the regex checks for either `labs.` or `labs-` The redirects were rearranged to put the labs.quansight.com entry first. Otherwise the redirects that are internal to qs.com can mess up pass-through paths to labs.quansight.org. Right now `/blog` is the main one, but there might be others...
1 parent f465af6 commit 36cbf66

File tree

1 file changed

+51
-7
lines changed

1 file changed

+51
-7
lines changed

apps/consulting/next.config.js

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,55 @@ const withNx = require('@nrwl/next/plugins/with-nx');
77
const nextConfig = {
88
async redirects() {
99
return [
10+
{
11+
source: '/:path*',
12+
has: [
13+
{
14+
/* The purpose of this redirect is to take all traffic entering at
15+
https://labs.quansight.com/:path and redirect it to
16+
https://labs.quansight.org/:path. The value here is a regex
17+
matching the host of an incoming request, which will find
18+
the initial `labs.` of https://labs.quansight.com.
19+
20+
The reason why a literal `labs.quansight.com` was not used
21+
was to allow testing of the redirect before deployment.
22+
During work on the PR, a temporary Vercel deployment was
23+
created with a `labs-` prefix on the domain, to trigger
24+
this redirect. (Vercel does not allow multiple layers of
25+
subdomains on deployment URLs, so a `labs.` prefix
26+
was not an option.) This is why the regex includes the `[.-]`
27+
character class, instead of just `\\.` to match a period.
28+
29+
While a tighter scope on this host regex match would probably
30+
be ideal, since we are not planning on using anything other
31+
than the apex quansight.com domain for the website
32+
this configuration should not cause problems.
33+
34+
Note that this redirect configuration requires that *BOTH*
35+
`quansight.com` *and* `labs.quansight.com` be configured
36+
as active domains for the `main` branch under the Vercel
37+
project responsible for live deployment of the website.
38+
Otherwise, incoming traffic to `labs.quansight.com/:path`
39+
will receive a Vercel "no deployment at this address"
40+
404 error.
41+
42+
This redirect is placed first in the sequence so that
43+
all incoming traffic to a labs.quansight.com/:path is
44+
forwarded to labs.quansight.org/:path without being
45+
modified by the other redirects below.
46+
*/
47+
type: 'host',
48+
value: '^labs[.-].+',
49+
},
50+
],
51+
permanent: true,
52+
destination: 'https://labs.quansight.org/:path*',
53+
},
54+
{
55+
source: '/labs',
56+
permanent: true,
57+
destination: 'https://labs.quansight.org',
58+
},
1059
{
1160
source: '/library',
1261
has: [
@@ -19,20 +68,15 @@ const nextConfig = {
1968
permanent: false,
2069
destination: '/library?page=1',
2170
},
22-
{
23-
source: '/blog',
24-
permanent: true,
25-
destination: '/library?page=1&type=blog',
26-
},
2771
{
2872
source: '/staffing',
2973
permanent: true,
3074
destination: '/careers',
3175
},
3276
{
33-
source: '/labs',
77+
source: '/blog',
3478
permanent: true,
35-
destination: 'https://labs.quansight.org',
79+
destination: '/library?page=1&type=blog',
3680
},
3781
];
3882
},

0 commit comments

Comments
 (0)