diff --git a/next.config.js b/next.config.js index f0a623d4e..40d899f7a 100644 --- a/next.config.js +++ b/next.config.js @@ -2,6 +2,10 @@ module.exports = { env: { commitTag: process.env.COMMIT_TAG || 'local', }, + publicRuntimeConfig: { + // Will be available on both server and client + JELLYFIN_TYPE: process.env.JELLYFIN_TYPE, + }, images: { domains: ['image.tmdb.org'], }, diff --git a/src/components/IssueDetails/index.tsx b/src/components/IssueDetails/index.tsx index ab04664df..3d670caf4 100644 --- a/src/components/IssueDetails/index.tsx +++ b/src/components/IssueDetails/index.tsx @@ -35,6 +35,7 @@ import IssueComment from './IssueComment'; import IssueDescription from './IssueDescription'; import { MediaServerType } from '../../../server/constants/server'; import useSettings from '../../hooks/useSettings'; +import getConfig from 'next/config'; const messages = defineMessages({ openedby: '#{issueId} opened {relativeTime} by {username}', @@ -99,6 +100,7 @@ const IssueDetails: React.FC = () => { (opt) => opt.issueType === issueData?.issueType ); const settings = useSettings(); + const { publicRuntimeConfig } = getConfig(); if (!data && !error) { return ; @@ -366,7 +368,7 @@ const IssueDetails: React.FC = () => { > - {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.playonplex, { mediaServerName: 'Emby', }) @@ -412,7 +414,7 @@ const IssueDetails: React.FC = () => { > - {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.play4konplex, { mediaServerName: 'Emby', }) @@ -628,7 +630,7 @@ const IssueDetails: React.FC = () => { > - {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.playonplex, { mediaServerName: 'Emby', }) @@ -674,7 +676,7 @@ const IssueDetails: React.FC = () => { > - {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.play4konplex, { mediaServerName: 'Emby', }) diff --git a/src/components/Login/JellyfinLogin.tsx b/src/components/Login/JellyfinLogin.tsx index a6cb0c0c1..e76a16502 100644 --- a/src/components/Login/JellyfinLogin.tsx +++ b/src/components/Login/JellyfinLogin.tsx @@ -6,6 +6,7 @@ import { useToasts } from 'react-toast-notifications'; import * as Yup from 'yup'; import useSettings from '../../hooks/useSettings'; import Button from '../Common/Button'; +import getConfig from 'next/config'; const messages = defineMessages({ username: 'Username', @@ -39,21 +40,19 @@ const JellyfinLogin: React.FC = ({ const toasts = useToasts(); const intl = useIntl(); const settings = useSettings(); + const { publicRuntimeConfig } = getConfig(); if (initial) { const LoginSchema = Yup.object().shape({ host: Yup.string() .matches( /^(?:(?:(?:https?):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/, - intl.formatMessage(messages.validationhostformat, { - mediaServerName: - process.env.JELLYFIN_TYPE == 'emby' ? 'Emby' : 'Jellyfin', - }) + intl.formatMessage(messages.validationhostformat) ) .required( intl.formatMessage(messages.validationhostrequired, { mediaServerName: - process.env.JELLYFIN_TYPE == 'emby' ? 'Emby' : 'Jellyfin', + publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? 'Emby' : 'Jellyfin', }) ), email: Yup.string() @@ -104,7 +103,9 @@ const JellyfinLogin: React.FC = ({
@@ -115,7 +116,7 @@ const JellyfinLogin: React.FC = ({ type="text" placeholder={intl.formatMessage(messages.host, { mediaServerName: - process.env.JELLYFIN_TYPE == 'emby' + publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? 'Emby' : 'Jellyfin', })} diff --git a/src/components/MovieDetails/index.tsx b/src/components/MovieDetails/index.tsx index 0ba0b9279..3e33c4b8a 100644 --- a/src/components/MovieDetails/index.tsx +++ b/src/components/MovieDetails/index.tsx @@ -48,6 +48,7 @@ import PersonCard from '../PersonCard'; import RequestButton from '../RequestButton'; import Slider from '../Slider'; import StatusBadge from '../StatusBadge'; +import getConfig from 'next/config'; const messages = defineMessages({ originaltitle: 'Original Title', @@ -95,6 +96,7 @@ const MovieDetails: React.FC = ({ movie }) => { const minStudios = 3; const [showMoreStudios, setShowMoreStudios] = useState(false); const [showIssueModal, setShowIssueModal] = useState(false); + const { publicRuntimeConfig } = getConfig(); const { data, @@ -223,7 +225,7 @@ const MovieDetails: React.FC = ({ movie }) => { ?.flatrate ?? []; function getAvalaibleMediaServerName() { - if (process.env.JELLYFIN_TYPE === 'emby') { + if (publicRuntimeConfig.JELLYFIN_TYPE === 'emby') { return intl.formatMessage(messages.play, { mediaServerName: 'Emby' }); } @@ -235,7 +237,7 @@ const MovieDetails: React.FC = ({ movie }) => { } function getAvalaible4kMediaServerName() { - if (process.env.JELLYFIN_TYPE === 'emby') { + if (publicRuntimeConfig.JELLYFIN_TYPE === 'emby') { return intl.formatMessage(messages.play4k, { mediaServerName: 'Emby' }); } diff --git a/src/components/Settings/SettingsJellyfin.tsx b/src/components/Settings/SettingsJellyfin.tsx index 5a5d4ffa2..4974c84bd 100644 --- a/src/components/Settings/SettingsJellyfin.tsx +++ b/src/components/Settings/SettingsJellyfin.tsx @@ -12,6 +12,7 @@ import Badge from '../Common/Badge'; import Button from '../Common/Button'; import LoadingSpinner from '../Common/LoadingSpinner'; import LibraryItem from './LibraryItem'; +import getConfig from 'next/config'; const messages = defineMessages({ jellyfinsettings: '{mediaServerName} Settings', @@ -80,6 +81,7 @@ const SettingsJellyfin: React.FC = ({ ); const intl = useIntl(); const { addToast } = useToasts(); + const { publicRuntimeConfig } = getConfig(); const JellyfinSettingsSchema = Yup.object().shape({ jellyfinExternalUrl: Yup.string().matches( @@ -161,7 +163,7 @@ const SettingsJellyfin: React.FC = ({ <>

- {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.jellyfinlibraries, { mediaServerName: 'Emby', }) @@ -170,7 +172,7 @@ const SettingsJellyfin: React.FC = ({ })}

- {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.jellyfinlibrariesDescription, { mediaServerName: 'Emby', }) @@ -213,7 +215,7 @@ const SettingsJellyfin: React.FC = ({

- {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.manualscanDescriptionJellyfin, { mediaServerName: 'Emby', }) @@ -323,7 +325,7 @@ const SettingsJellyfin: React.FC = ({ <>

- {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.jellyfinSettings, { mediaServerName: 'Emby', }) @@ -332,7 +334,7 @@ const SettingsJellyfin: React.FC = ({ })}

- {process.env.JELLYFIN_TYPE == 'emby' + {publicRuntimeConfig.JELLYFIN_TYPE == 'emby' ? intl.formatMessage(messages.jellyfinSettingsDescription, { mediaServerName: 'Emby', }) @@ -355,7 +357,9 @@ const SettingsJellyfin: React.FC = ({ addToast( intl.formatMessage(messages.jellyfinSettingsSuccess, { mediaServerName: - process.env.JELLYFIN_TYPE == 'emby' ? 'Emby' : 'Jellyfin', + publicRuntimeConfig.JELLYFIN_TYPE == 'emby' + ? 'Emby' + : 'Jellyfin', }), { autoDismiss: true, @@ -366,7 +370,9 @@ const SettingsJellyfin: React.FC = ({ addToast( intl.formatMessage(messages.jellyfinSettingsFailure, { mediaServerName: - process.env.JELLYFIN_TYPE == 'emby' ? 'Emby' : 'Jellyfin', + publicRuntimeConfig.JELLYFIN_TYPE == 'emby' + ? 'Emby' + : 'Jellyfin', }), { autoDismiss: true, diff --git a/src/components/Settings/SettingsLayout.tsx b/src/components/Settings/SettingsLayout.tsx index 23af1c632..3963d5c5e 100644 --- a/src/components/Settings/SettingsLayout.tsx +++ b/src/components/Settings/SettingsLayout.tsx @@ -3,6 +3,7 @@ import { defineMessages, useIntl } from 'react-intl'; import globalMessages from '../../i18n/globalMessages'; import PageTitle from '../Common/PageTitle'; import SettingsTabs, { SettingsRoute } from '../Common/SettingsTabs'; +import getConfig from 'next/config'; const messages = defineMessages({ menuGeneralSettings: 'General', @@ -18,6 +19,7 @@ const messages = defineMessages({ const SettingsLayout: React.FC = ({ children }) => { const intl = useIntl(); + const { publicRuntimeConfig } = getConfig(); const settingsRoutes: SettingsRoute[] = [ { text: intl.formatMessage(messages.menuGeneralSettings), @@ -76,7 +78,7 @@ const SettingsLayout: React.FC = ({ children }) => { ); function getAvalaibleMediaServerName() { - if (process.env.JELLYFIN_TYPE === 'emby') { + if (publicRuntimeConfig.JELLYFIN_TYPE === 'emby') { return intl.formatMessage(messages.menuJellyfinSettings, { mediaServerName: 'Emby', }); diff --git a/src/components/Settings/SettingsUsers/index.tsx b/src/components/Settings/SettingsUsers/index.tsx index 03232f884..89c89673d 100644 --- a/src/components/Settings/SettingsUsers/index.tsx +++ b/src/components/Settings/SettingsUsers/index.tsx @@ -14,6 +14,7 @@ import LoadingSpinner from '../../Common/LoadingSpinner'; import PageTitle from '../../Common/PageTitle'; import PermissionEdit from '../../PermissionEdit'; import QuotaSelector from '../../QuotaSelector'; +import getConfig from 'next/config'; const messages = defineMessages({ users: 'Users', @@ -42,6 +43,7 @@ const SettingsUsers: React.FC = () => { mutate: revalidate, } = useSWR('/api/v1/settings/main'); const settings = useSettings(); + const { publicRuntimeConfig } = getConfig(); if (!data && !error) { return ; @@ -131,7 +133,7 @@ const SettingsUsers: React.FC = () => {