diff --git a/apps/api/plane/settings/common.py b/apps/api/plane/settings/common.py index 523f6b7ced..ea37e2abe3 100644 --- a/apps/api/plane/settings/common.py +++ b/apps/api/plane/settings/common.py @@ -399,6 +399,10 @@ LIVE_BASE_PATH = os.environ.get("LIVE_BASE_PATH", "live/") LIVE_URL = urljoin(LIVE_BASE_URL, LIVE_BASE_PATH) if LIVE_BASE_URL else None LIVE_SERVER_SECRET_KEY = os.environ.get("LIVE_SERVER_SECRET_KEY", "") +PI_BASE_URL = os.environ.get("PI_BASE_URL", "") +PI_BASE_PATH = os.environ.get("PI_BASE_PATH", "/pi") +PI_URL = urljoin(PI_BASE_URL, PI_BASE_PATH) + # WEB URL WEB_URL = os.environ.get("WEB_URL") diff --git a/apps/dev-wiki/helpers/common.helper.ts b/apps/dev-wiki/helpers/common.helper.ts index 03b623a840..c676c0d788 100644 --- a/apps/dev-wiki/helpers/common.helper.ts +++ b/apps/dev-wiki/helpers/common.helper.ts @@ -2,7 +2,10 @@ import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || ""; -export const PI_BASE_URL = process.env.NEXT_PUBLIC_PI_BASE_URL || "https://dev.plane-pi.plane.town"; + +export const PI_BASE_URL = process.env.NEXT_PUBLIC_PI_BASE_URL || ""; +export const PI_BASE_PATH = process.env.NEXT_PUBLIC_PI_BASE_PATH || ""; +export const PI_URL = encodeURI(`${PI_BASE_URL}${PI_BASE_PATH}`); export const ADMIN_BASE_URL = process.env.NEXT_PUBLIC_ADMIN_BASE_URL || ""; export const ADMIN_BASE_PATH = process.env.NEXT_PUBLIC_ADMIN_BASE_PATH || ""; diff --git a/apps/web/.env.example b/apps/web/.env.example index 34ad34a907..adae16d4b3 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -13,3 +13,6 @@ NEXT_PUBLIC_LIVE_BASE_PATH="/live" NEXT_PUBLIC_SILO_BASE_URL="http://localhost:3200" NEXT_PUBLIC_SILO_BASE_PATH="/silo" + +NEXT_PUBLIC_PI_BASE_URL="http://127.0.0.1:8001" +NEXT_PUBLIC_PI_BASE_PATH="/pi" \ No newline at end of file diff --git a/apps/web/Dockerfile.web b/apps/web/Dockerfile.web index 38410596c5..56d1b06985 100644 --- a/apps/web/Dockerfile.web +++ b/apps/web/Dockerfile.web @@ -71,6 +71,12 @@ ENV NEXT_PUBLIC_SILO_BASE_URL=$NEXT_PUBLIC_SILO_BASE_URL ARG NEXT_PUBLIC_SILO_BASE_PATH="/silo" ENV NEXT_PUBLIC_SILO_BASE_PATH=$NEXT_PUBLIC_SILO_BASE_PATH +ARG NEXT_PUBLIC_PI_BASE_URL="" +ENV NEXT_PUBLIC_PI_BASE_URL=$NEXT_PUBLIC_PI_BASE_URL + +ARG NEXT_PUBLIC_PI_BASE_PATH="/pi" +ENV NEXT_PUBLIC_PI_BASE_PATH=$NEXT_PUBLIC_PI_BASE_PATH + ENV NEXT_TELEMETRY_DISABLED=1 ENV TURBO_TELEMETRY_DISABLED=1 @@ -118,6 +124,12 @@ ENV NEXT_PUBLIC_SPACE_BASE_PATH=$NEXT_PUBLIC_SPACE_BASE_PATH ARG NEXT_PUBLIC_WEB_BASE_URL="" ENV NEXT_PUBLIC_WEB_BASE_URL=$NEXT_PUBLIC_WEB_BASE_URL +ARG NEXT_PUBLIC_PI_BASE_URL="" +ENV NEXT_PUBLIC_PI_BASE_URL=$NEXT_PUBLIC_PI_BASE_URL + +ARG NEXT_PUBLIC_PI_BASE_PATH="/pi" +ENV NEXT_PUBLIC_PI_BASE_PATH=$NEXT_PUBLIC_PI_BASE_PATH + ENV NEXT_TELEMETRY_DISABLED=1 ENV TURBO_TELEMETRY_DISABLED=1 diff --git a/apps/web/ee/components/pi-chat/conversation/ai-message.tsx b/apps/web/ee/components/pi-chat/conversation/ai-message.tsx index 6c444261c3..ba8cf178b3 100644 --- a/apps/web/ee/components/pi-chat/conversation/ai-message.tsx +++ b/apps/web/ee/components/pi-chat/conversation/ai-message.tsx @@ -3,7 +3,7 @@ import { useParams } from "next/navigation"; import Markdown from "react-markdown"; import remarkGfm from "remark-gfm"; // plane imports -import { PI_BASE_URL } from "@plane/constants"; +import { PI_URL } from "@plane/constants"; import { Loader } from "@plane/ui"; // plane-web imports import { useWorkspace } from "@/hooks/store/use-workspace"; @@ -43,7 +43,7 @@ export const AiMessage = observer((props: TProps) => { className="pi-chat-root [&>*:first-child]:mt-0 animate-fade-in" components={{ a: ({ children, href }) => - href?.startsWith(`${PI_BASE_URL}/api/v1/oauth/authorize/`) && !isLatest ? ( // NOTE: Prev auth links shouldn't be accessible + href?.startsWith(`${PI_URL}/api/v1/oauth/authorize/`) && !isLatest ? ( // NOTE: Prev auth links shouldn't be accessible {children} ) : ( diff --git a/apps/web/ee/services/pi-chat.service.ts b/apps/web/ee/services/pi-chat.service.ts index ffdad71e27..c5bc6d35ce 100644 --- a/apps/web/ee/services/pi-chat.service.ts +++ b/apps/web/ee/services/pi-chat.service.ts @@ -1,6 +1,6 @@ // constants import type { AxiosRequestConfig } from "axios"; -import { PI_BASE_URL } from "@plane/constants"; +import { PI_URL } from "@plane/constants"; import { getFileMetaDataForUpload, generateFileUploadPayload } from "@plane/services"; // services import { APIService } from "@/services/api.service"; @@ -62,13 +62,13 @@ export const getPiFileURL = (path: string): string | undefined => { if (!path) return undefined; const isValidURL = path.startsWith("http"); if (isValidURL) return path; - return `${PI_BASE_URL}${path}`; + return `${PI_URL}${path}`; }; export class PiChatService extends APIService { private fileUploadService: FileUploadService; constructor() { - super(PI_BASE_URL); + super(PI_URL); // upload service this.fileUploadService = new FileUploadService(); } diff --git a/apps/web/ee/services/pi.service.ts b/apps/web/ee/services/pi.service.ts index 884fc4129e..d7e1e516a2 100644 --- a/apps/web/ee/services/pi.service.ts +++ b/apps/web/ee/services/pi.service.ts @@ -1,12 +1,12 @@ // plane imports -import { PI_BASE_URL } from "@plane/constants"; +import { PI_URL } from "@plane/constants"; import type { TDuplicateIssuePayload, TDuplicateIssueResponse } from "@plane/types"; // services import { APIService } from "@/services/api.service"; export class PIService extends APIService { constructor() { - super(PI_BASE_URL); + super(PI_URL); } async getDuplicateIssues(data: Partial): Promise { diff --git a/apps/web/ee/store/pi-chat/pi-chat.ts b/apps/web/ee/store/pi-chat/pi-chat.ts index 6161a08f7f..9cfbe4bf31 100644 --- a/apps/web/ee/store/pi-chat/pi-chat.ts +++ b/apps/web/ee/store/pi-chat/pi-chat.ts @@ -2,7 +2,7 @@ import { update, set, isEmpty } from "lodash-es"; import { action, computed, makeObservable, observable, runInAction } from "mobx"; import { computedFn } from "mobx-utils"; // plane imports -import { PI_BASE_URL } from "@plane/constants"; +import { PI_URL } from "@plane/constants"; // plane web imports import { WorkspaceService } from "@/plane-web/services"; import { PiChatService } from "@/plane-web/services/pi-chat.service"; @@ -362,7 +362,7 @@ export class PiChatStore implements IPiChatStore { workspaceId: string | undefined, newDialogue: TDialogue ) => { - const url = `${PI_BASE_URL}/api/v1/chat/stream-answer/${token}`; + const url = `${PI_URL}/api/v1/chat/stream-answer/${token}`; const eventSource = new EventSource(url, { withCredentials: true, diff --git a/packages/constants/src/endpoints-extended.ts b/packages/constants/src/endpoints-extended.ts index fde4ab5944..dae03d9dc9 100644 --- a/packages/constants/src/endpoints-extended.ts +++ b/packages/constants/src/endpoints-extended.ts @@ -1,2 +1,4 @@ // PI Base Url -export const PI_BASE_URL = process.env.NEXT_PUBLIC_PI_BASE_URL || "https://dev.plane-pi.plane.town"; +export const PI_BASE_URL = process.env.NEXT_PUBLIC_PI_BASE_URL || ""; +export const PI_BASE_PATH = process.env.NEXT_PUBLIC_PI_BASE_PATH || ""; +export const PI_URL = encodeURI(`${PI_BASE_URL}${PI_BASE_PATH}`);