fix(docker): 🐛 Runtime public environment
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
# Don't edit this file
|
||||
NEXT_PUBLIC_VIEWER_URL=DOCKER_NEXT_PUBLIC_VIEWER_URL
|
||||
NEXT_PUBLIC_VIEWER_URL=
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { isEmpty } from 'utils'
|
||||
import { env, isEmpty } from 'utils'
|
||||
|
||||
export const ErrorPage = ({ error }: { error: Error }) => {
|
||||
return (
|
||||
@@ -12,7 +12,7 @@ export const ErrorPage = ({ error }: { error: Error }) => {
|
||||
flexDirection: 'column',
|
||||
}}
|
||||
>
|
||||
{isEmpty(process.env.NEXT_PUBLIC_VIEWER_URL) ? (
|
||||
{isEmpty(env('VIEWER_URL')) ? (
|
||||
<>
|
||||
<h1 style={{ fontWeight: 'bold', fontSize: '30px' }}>
|
||||
NEXT_PUBLIC_VIEWER_URL is missing
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"dx": "yarn dev",
|
||||
"dev": "next dev -p 3001",
|
||||
"build": "next build",
|
||||
"dev": "ENVSH_ENV=.env.local bash ../../env.sh next dev -p 3001",
|
||||
"build": "cp .env.docker .env.production && ENVSH_ENV=.env.production bash ../../env.sh next build",
|
||||
"build:docker": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"test": "yarn playwright test",
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
31
apps/viewer/pages/_document.tsx
Normal file
31
apps/viewer/pages/_document.tsx
Normal 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
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CollaborationType, Prisma, User, WorkspaceRole } from 'db'
|
||||
import { isNotEmpty } from 'utils'
|
||||
import { env } from 'utils'
|
||||
|
||||
const parseWhereFilter = (
|
||||
typebotIds: string[] | string,
|
||||
@@ -20,7 +20,7 @@ const parseWhereFilter = (
|
||||
id: typeof typebotIds === 'string' ? typebotIds : { in: typebotIds },
|
||||
workspace:
|
||||
(type === 'read' && user.email === process.env.ADMIN_EMAIL) ||
|
||||
isNotEmpty(process.env.NEXT_PUBLIC_E2E_TEST)
|
||||
env('E2E_TEST') === 'enabled'
|
||||
? undefined
|
||||
: {
|
||||
members: {
|
||||
|
||||
Reference in New Issue
Block a user