2
0

🔧 Fix landing page loading issue with query params

Closes #1560
This commit is contained in:
Baptiste Arnaud
2024-06-11 10:03:40 +02:00
parent fdbd9c08a3
commit 40ca02df8c

View File

@ -37,8 +37,23 @@ const landingPagePaths = [
'/about',
'/oss-friends',
'/blog',
'/blog/:slug*',
]
const landingPageReferers = [
'/',
'/pricing',
'/privacy-policies',
'/terms-of-service',
'/about',
'/oss-friends',
'/blog',
].concat(['/blog/(.+)'])
const currentHost = 'typebot.io'
const currentOrigin = `https://${currentHost}`
const optionalQueryParams = `(\\/?\\?.*)?`
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
@ -72,39 +87,39 @@ const nextConfig = {
async rewrites() {
return {
beforeFiles: (process.env.LANDING_PAGE_URL
? landingPagePaths
? landingPageReferers
.map((path) => ({
source: '/_next/static/:static*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io${path}`,
value: `${currentOrigin}${path}${optionalQueryParams}`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/_next/static/:static*`,
}))
.concat(
landingPagePaths.map((path) => ({
landingPageReferers.map((path) => ({
source: '/typebots/:typebot*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io${path}`,
value: `${currentOrigin}${path}${optionalQueryParams}`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/typebots/:typebot*`,
}))
)
.concat(
landingPagePaths.map((path) => ({
landingPageReferers.map((path) => ({
source: '/styles/:style*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io${path}`,
value: `${currentOrigin}${path}${optionalQueryParams}`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/styles/:style*`,
@ -116,79 +131,25 @@ const nextConfig = {
has: [
{
type: 'host',
value: 'typebot.io',
value: currentHost,
},
],
destination: `${process.env.LANDING_PAGE_URL}${path}`,
}))
)
.concat([
{
source: '/blog/:slug',
has: [
{
type: 'host',
value: 'typebot.io',
},
],
destination: `${process.env.LANDING_PAGE_URL}/blog/:slug`,
},
{
source: '/_next/static/:static*',
.concat(
landingPageReferers.map((path) => ({
source: '/images/:image*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io/blog/(?<slug>.*)`,
value: `${currentOrigin}${path}${optionalQueryParams}`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/_next/static/:static*`,
},
{
source: '/images/blog/:images*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io/blog/(?<slug>.*)`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/images/blog/:images*`,
},
{
source: '/images/blog/:images*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io/blog`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/images/blog/:images*`,
},
{
source: '/typebots/:typebot*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io/blog/(?<slug>.*)`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/typebots/:typebot*`,
},
{
source: '/styles/:style*',
has: [
{
type: 'header',
key: 'referer',
value: `https://typebot.io/blog/(?<slug>.*)`,
},
],
destination: `${process.env.LANDING_PAGE_URL}/styles/:style*`,
},
])
destination: `${process.env.LANDING_PAGE_URL}/images/:image*`,
}))
)
: []
)
.concat([