diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml
index 3ba63cc26..b41711109 100644
--- a/docker/docker-compose.dev.yml
+++ b/docker/docker-compose.dev.yml
@@ -16,6 +16,11 @@ services:
- ../api/migrations:/app/migrations
#- ../api/node_modules:/app/node_modules
command: ["npm", "run", "start:debug"]
+
+ hexabot-frontend:
+ build:
+ context: ../
+ dockerfile: ./frontend/Dockerfile
mongo-express:
container_name: mongoUi
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 80102c667..5549acf3a 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -30,7 +30,6 @@ services:
condition: service_healthy
database-init:
condition: service_completed_successfully
-
healthcheck:
test: "wget --spider http://localhost:3000"
interval: 10s
@@ -40,12 +39,7 @@ services:
hexabot-frontend:
container_name: frontend
- build:
- context: ../
- dockerfile: ./frontend/Dockerfile
- args:
- - NEXT_PUBLIC_API_ORIGIN=${NEXT_PUBLIC_API_ORIGIN}
- - NEXT_PUBLIC_SSO_ENABLED=${NEXT_PUBLIC_SSO_ENABLED}
+ image: hexabot-ui:latest
env_file: .env
ports:
- ${APP_FRONTEND_PORT}:8080
diff --git a/frontend/Dockerfile b/frontend/Dockerfile
index cea1c11ba..d8d812c6b 100644
--- a/frontend/Dockerfile
+++ b/frontend/Dockerfile
@@ -21,14 +21,6 @@ RUN \
# Rebuild the source code only when needed
FROM base AS builder
-ARG NEXT_PUBLIC_API_ORIGIN
-ENV NEXT_PUBLIC_API_ORIGIN=${NEXT_PUBLIC_API_ORIGIN}
-ARG NEXT_PUBLIC_SSO_ENABLED
-ENV NEXT_PUBLIC_SSO_ENABLED=${NEXT_PUBLIC_SSO_ENABLED}
-
-ENV REACT_APP_WIDGET_API_URL=${NEXT_PUBLIC_API_ORIGIN}
-ENV REACT_APP_WIDGET_CHANNEL=test
-ENV REACT_APP_WIDGET_TOKEN=test
WORKDIR /app
@@ -57,10 +49,6 @@ ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1
-# Set the environment variable API_ORIGIN
-ENV NEXT_PUBLIC_API_ORIGIN ${NEXT_PUBLIC_API_ORIGIN:-"http://localhost:3000"}
-ENV NEXT_PUBLIC_SSO_ENABLED ${NEXT_PUBLIC_SSO_ENABLED:-"false"}
-
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs
index 774cf83ff..6d0080dfb 100644
--- a/frontend/next.config.mjs
+++ b/frontend/next.config.mjs
@@ -1,36 +1,24 @@
/** @type {import('next').NextConfig} */
import withTM from "next-transpile-modules";
-const apiUrl = process.env.NEXT_PUBLIC_API_ORIGIN || "http://localhost:4000/";
-const url = new URL(apiUrl);
const nextConfig = withTM(["hexabot-widget"])({
+ async rewrites() {
+ return [
+ {
+ source: "/config",
+ destination: "/api/config",
+ },
+ ];
+ },
webpack(config, _options) {
return config;
},
publicRuntimeConfig: {
- apiUrl,
- ssoEnabled: process.env.NEXT_PUBLIC_SSO_ENABLED === "true",
lang: {
default: "en",
},
},
output: "standalone",
- images: {
- remotePatterns: [
- {
- protocol: "https",
- hostname: url.hostname,
- port: url.port,
- pathname: "/attachment/**",
- },
- {
- protocol: "http",
- hostname: url.hostname,
- port: url.port,
- pathname: "/attachment/**",
- },
- ],
- },
});
export default nextConfig;
diff --git a/frontend/src/app-components/tables/columns/renderPicture.tsx b/frontend/src/app-components/tables/columns/renderPicture.tsx
index 33af17406..3684a00a7 100644
--- a/frontend/src/app-components/tables/columns/renderPicture.tsx
+++ b/frontend/src/app-components/tables/columns/renderPicture.tsx
@@ -11,12 +11,15 @@ import { Grid } from "@mui/material";
import { GridRenderCellParams } from "@mui/x-data-grid";
import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
+import { useConfig } from "@/hooks/useConfig";
import { EntityType } from "@/services/types";
export const buildRenderPicture = (
entityType: EntityType.USER | EntityType.SUBSCRIBER,
) =>
function RenderPicture(params: GridRenderCellParams) {
+ const { apiUrl } = useConfig();
+
return (
@@ -118,6 +123,7 @@ export function Chat() {
i18n.language,
)}`}
src={getAvatarSrc(
+ apiUrl,
message.sender
? EntityType.SUBSCRIBER
: EntityType.USER,
diff --git a/frontend/src/components/inbox/components/ChatActions.tsx b/frontend/src/components/inbox/components/ChatActions.tsx
index b91f5cc97..605ab2e4c 100644
--- a/frontend/src/components/inbox/components/ChatActions.tsx
+++ b/frontend/src/components/inbox/components/ChatActions.tsx
@@ -18,12 +18,14 @@ import { Input } from "@/app-components/inputs/Input";
import { useFind } from "@/hooks/crud/useFind";
import { useUpdate } from "@/hooks/crud/useUpdate";
import { useAuth } from "@/hooks/useAuth";
+import { useConfig } from "@/hooks/useConfig";
import { EntityType } from "@/services/types";
import { getAvatarSrc } from "../helpers/mapMessages";
import { useChat } from "../hooks/ChatContext";
export const ChatActions = () => {
+ const { apiUrl } = useConfig();
const { t } = useTranslation();
const { subscriber: activeChat } = useChat();
const [takeoverBy, setTakeoverBy] = useState(
@@ -57,7 +59,7 @@ export const ChatActions = () => {
diff --git a/frontend/src/components/inbox/components/ConversationsList.tsx b/frontend/src/components/inbox/components/ConversationsList.tsx
index b032f514a..666cadd4f 100644
--- a/frontend/src/components/inbox/components/ConversationsList.tsx
+++ b/frontend/src/components/inbox/components/ConversationsList.tsx
@@ -16,6 +16,7 @@ import InboxIcon from "@mui/icons-material/MoveToInbox";
import { Chip, debounce, Grid } from "@mui/material";
import { useTranslation } from "react-i18next";
+import { useConfig } from "@/hooks/useConfig";
import { Title } from "@/layout/content/Title";
import { EntityType } from "@/services/types";
@@ -29,6 +30,7 @@ export const SubscribersList = (props: {
searchPayload: any;
assignedTo: AssignedTo;
}) => {
+ const { apiUrl } = useConfig();
const { t, i18n } = useTranslation();
const chat = useChat();
const { fetchNextPage, isFetching, subscribers, hasNextPage } =
@@ -58,6 +60,7 @@ export const SubscribersList = (props: {
>
}
diff --git a/frontend/src/components/users/index.tsx b/frontend/src/components/users/index.tsx
index a77391bf1..6cde7a77f 100644
--- a/frontend/src/components/users/index.tsx
+++ b/frontend/src/components/users/index.tsx
@@ -11,7 +11,6 @@ import { faUsers } from "@fortawesome/free-solid-svg-icons";
import PersonAddAlt1Icon from "@mui/icons-material/PersonAddAlt1";
import { Button, Grid, Paper } from "@mui/material";
import { GridColDef } from "@mui/x-data-grid";
-import getConfig from "next/config";
import { useTranslation } from "react-i18next";
import { ChipEntity } from "@/app-components/displays/ChipEntity";
@@ -25,6 +24,7 @@ import { buildRenderPicture } from "@/app-components/tables/columns/renderPictur
import { DataGrid } from "@/app-components/tables/DataGrid";
import { useFind } from "@/hooks/crud/useFind";
import { useUpdate } from "@/hooks/crud/useUpdate";
+import { useConfig } from "@/hooks/useConfig";
import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
import { useHasPermission } from "@/hooks/useHasPermission";
import { useSearch } from "@/hooks/useSearch";
@@ -39,9 +39,8 @@ import { getDateTimeFormatter } from "@/utils/date";
import { EditUserDialog } from "./EditUserDialog";
import { InvitationDialog } from "./InvitationDialog";
-const { publicRuntimeConfig } = getConfig();
-
export const Users = () => {
+ const { ssoEnabled } = useConfig();
const { t } = useTranslation();
const { toast } = useToast();
const { mutateAsync: updateUser } = useUpdate(EntityType.USER, {
@@ -157,7 +156,7 @@ export const Users = () => {
},
});
}}
- disabled={publicRuntimeConfig.ssoEnabled}
+ disabled={ssoEnabled}
>
{t(params.row.state ? "label.enabled" : "label.disabled")}
@@ -188,7 +187,7 @@ export const Users = () => {
valueGetter: (params) =>
t("datetime.updated_at", getDateTimeFormatter(params)),
},
- ...(!publicRuntimeConfig.ssoEnabled ? [actionColumns] : []),
+ ...(!ssoEnabled ? [actionColumns] : []),
];
return (
@@ -207,7 +206,7 @@ export const Users = () => {
- {!publicRuntimeConfig.ssoEnabled &&
+ {!ssoEnabled &&
hasPermission(EntityType.USER, PermissionAction.CREATE) ? (