2
0

fix(docker): 🐛 Runtime public environment

This commit is contained in:
Baptiste Arnaud
2022-06-21 10:36:41 +02:00
parent ea765640cf
commit e03fe9f7d9
54 changed files with 349 additions and 164 deletions

View File

@ -3,7 +3,7 @@ import { NotFoundPage } from 'layouts/NotFoundPage'
import { PublicTypebot } from 'models'
import { GetServerSideProps, GetServerSidePropsContext } from 'next'
import sanitizeHtml from 'sanitize-html'
import { isDefined, isNotDefined, omit } from 'utils'
import { env, isDefined, isNotDefined, omit } from 'utils'
import { TypebotPage, TypebotPageProps } from '../layouts/TypebotPage'
import prisma from '../libs/prisma'
@ -16,9 +16,9 @@ export const getServerSideProps: GetServerSideProps = async (
const { host, forwardedHost } = getHost(context.req)
try {
if (!host) return { props: {} }
const viewerUrls = (process.env.NEXT_PUBLIC_VIEWER_URL ?? '').split(',')
const viewerUrls = (env('VIEWER_URL') ?? '').split(',')
const isMatchingViewerUrl =
process.env.NEXT_PUBLIC_E2E_TEST === 'enabled'
env('E2E_TEST') === 'enabled'
? true
: viewerUrls.some(
(url) =>

View File

@ -0,0 +1,31 @@
import Document, {
Html,
Head,
Main,
NextScript,
DocumentContext,
} from 'next/document'
class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}
render() {
return (
<Html>
<Head>
{/* eslint-disable-next-line @next/next/no-sync-scripts */}
<script src="/__env.js" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument