removed some domain dependencies

This commit is contained in:
mrfry 2023-04-11 16:18:35 +02:00
parent f8d423f162
commit b854b035c7
3 changed files with 9 additions and 41 deletions

18
make.sh
View file

@ -1,18 +1,2 @@
#!/bin/bash
scriptPath=$(dirname -- "${0}")
domainPath="${scriptPath}/../../data/domain"
domain="${DOMAIN}"
if [ -z "${domain}" ] && [ -f "${domainPath}" ]; then
domain=$(cat "${domainPath}")
fi
if [ -z "${domain}" ]; then
echo -e "\033[0;41mDOMAIN is not set, and ${domainPath} does not exist!\033[0m"
exit 1
fi
NEXT_PUBLIC_DOMAIN="${domain}" npm run export
echo "Exported with domain: '${domain}'"
npm run export

View file

@ -1,20 +1,9 @@
// eslint-disable-next-line no-undef
const useLocalhost = process && process.env.NODE_ENV === 'development'
// eslint-disable-next-line no-undef
const domain = process && process.env.NEXT_PUBLIC_DOMAIN
if (!domain && !useLocalhost) {
throw new Error(
'Domain is not defined! Please set NEXT_PUBLIC_DOMAIN env variable!'
)
}
const constants = {
domain: domain || 'localhost',
siteUrl: useLocalhost ? 'http://localhost:8080/' : `https://${domain}/`,
apiUrl: useLocalhost
? 'http://localhost:8080/api/'
: `https://${domain}/api/`,
siteUrl: useLocalhost ? 'http://localhost:8080/' : '/',
apiUrl: useLocalhost ? 'http://localhost:8080/api/' : '/',
maxQuestionsToRender: 250,
}

View file

@ -13,6 +13,8 @@ import styles from './index.module.css'
import commonStyles from '../commonStyles.module.css'
import constants from '../constants.js'
const domain = typeof window !== 'undefined' ? window.location.domain : ''
const Infos = ({ onClick, renderOKButton }) => {
return (
<div className={commonStyles.infoContainer}>
@ -168,9 +170,7 @@ export default function Index({ router }) {
return (
<>
<Head>
<title>
Tárgyak - Data Editor | {constants.domain}
</title>
<title>Tárgyak - Data Editor | {domain}</title>
</Head>
<DbSelector
qdbs={qdbs}
@ -186,9 +186,7 @@ export default function Index({ router }) {
return (
<>
<Head>
<title>
Kérdések - Data Editor | {constants.domain}
</title>
<title>Kérdések - Data Editor | {domain}</title>
</Head>
<DbSelector
qdbs={qdbs}
@ -204,9 +202,7 @@ export default function Index({ router }) {
return (
<>
<Head>
<title>
Kérdés beküldés - Data Editor | {constants.domain}
</title>
<title>Kérdés beküldés - Data Editor | {domain}</title>
</Head>
<DbSelector
hideLockedDbs
@ -226,8 +222,7 @@ export default function Index({ router }) {
<>
<Head>
<title>
Kitöltetlen tesztek - Data Editor |{' '}
{constants.domain}
Kitöltetlen tesztek - Data Editor | {domain}
</title>
</Head>
<PossibleAnswers refetchDbs={refetchDbs} router={router} />