next.config.ts redirect subdomain with regex
Unanswered
American black bear posted this in #help-forum
American black bearOP
According to the AI over at gpt help I can create the following redirect to redirect from, say, foo.example.com -> example.com/bar
But when I do that, and try to test it with
the response generated comes back with a null location (either by asking for the location from the response object or by using
Am I entering my regex wrong, or is there perhaps a bug in the
Thanks!
{
source: '/:path*',
has: [
{
type: 'host',
value: 'foo.(?<domain>.+?)/',
},
],
destination: 'https://:domain/bar/',
},But when I do that, and try to test it with
unstable_getResponseFromNextConfig via a unit test like so: const response = await unstable_getResponseFromNextConfig({ url: 'https://foo.example.com', nextConfig })
expect(getRedirectUrl(response))
.toBe(`https://example.com/bar`)the response generated comes back with a null location (either by asking for the location from the response object or by using
getRedirectUrlAm I entering my regex wrong, or is there perhaps a bug in the
unstable_getResponseFromNextConfig? The GPT AI said it was a known issue, but IME AI's always say that to me once I question their initial answer.Thanks!