From fdd1123abebda4b0e47184dad34100f56dcb7d0a Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 15:50:41 +0000 Subject: [PATCH 01/13] chore: removed api url build arg from compose --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 448346239eb..5bb240d40b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,6 @@ services: dockerfile: ./web/Dockerfile.web args: DOCKER_BUILDKIT: 1 - NEXT_PUBLIC_API_BASE_URL: "http://localhost:8000" restart: always command: /usr/local/bin/start.sh web/server.js web depends_on: @@ -22,7 +21,6 @@ services: dockerfile: ./space/Dockerfile.space args: DOCKER_BUILDKIT: 1 - NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 restart: always command: /usr/local/bin/start.sh space/server.js space depends_on: From 287bf3b68eef09c8a0ce2da4c6bfae03558f95d6 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 15:52:11 +0000 Subject: [PATCH 02/13] chore: set public api default argument to black string for self hosted --- space/Dockerfile.space | 4 ++-- web/Dockerfile.web | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/space/Dockerfile.space b/space/Dockerfile.space index 453d3b66302..12c3091349e 100644 --- a/space/Dockerfile.space +++ b/space/Dockerfile.space @@ -21,7 +21,7 @@ COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json USER root -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL @@ -44,7 +44,7 @@ COPY --from=installer --chown=captain:plane /app/space/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/space/.next ./space/.next COPY --from=installer --chown=captain:plane /app/space/public ./space/public -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1 ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL diff --git a/web/Dockerfile.web b/web/Dockerfile.web index a0250e0baf7..c86754eeec3 100644 --- a/web/Dockerfile.web +++ b/web/Dockerfile.web @@ -13,7 +13,7 @@ FROM node:18-alpine AS installer RUN apk add --no-cache libc6-compat WORKDIR /app -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" # First install the dependencies (as they change less often) COPY .gitignore .gitignore @@ -45,7 +45,7 @@ COPY --from=installer /app/web/package.json . COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next -ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ARG NEXT_PUBLIC_API_BASE_URL="" ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL USER root From 1cd5428a758cdcf91f144f53092bb63fad15bb4a Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 16:17:21 +0000 Subject: [PATCH 03/13] chore: updated web services to accept blank string as API URL --- web/lib/auth.ts | 8 ++++---- web/services/ai.service.ts | 2 +- web/services/analytics.service.ts | 2 +- web/services/app-installations.service.ts | 2 +- web/services/authentication.service.ts | 2 +- web/services/cycles.service.ts | 2 +- web/services/estimates.service.ts | 2 +- web/services/file.service.ts | 2 +- web/services/inbox.service.ts | 2 +- web/services/integration/csv.services.ts | 2 +- web/services/integration/github.service.ts | 2 +- web/services/integration/index.ts | 2 +- web/services/integration/jira.service.ts | 2 +- web/services/issues.service.ts | 2 +- web/services/modules.service.ts | 2 +- web/services/notifications.service.ts | 2 +- web/services/pages.service.ts | 2 +- web/services/project-publish.service.ts | 2 +- web/services/project.service.ts | 2 +- web/services/reaction.service.ts | 2 +- web/services/state.service.ts | 2 +- web/services/user.service.ts | 2 +- web/services/views.service.ts | 2 +- web/services/workspace.service.ts | 2 +- 24 files changed, 27 insertions(+), 27 deletions(-) diff --git a/web/lib/auth.ts b/web/lib/auth.ts index 47a52663d1d..eb72c0f183f 100644 --- a/web/lib/auth.ts +++ b/web/lib/auth.ts @@ -9,7 +9,7 @@ export const requiredAuth = async (cookie?: string) => { if (!token) return null; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; + const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; let user: IUser | null = null; @@ -41,7 +41,7 @@ export const requiredAdmin = async (workspaceSlug: string, projectId: string, co const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; + const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; let memberDetail: IProjectMember | null = null; @@ -75,7 +75,7 @@ export const requiredWorkspaceAdmin = async (workspaceSlug: string, cookie?: str const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; + const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; let memberDetail: IWorkspaceMember | null = null; @@ -119,7 +119,7 @@ export const homePageRedirect = async (cookie?: string) => { let workspaces: IWorkspace[] = []; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so"; + const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; diff --git a/web/services/ai.service.ts b/web/services/ai.service.ts index ecb1ada52d1..1ea31335a62 100644 --- a/web/services/ai.service.ts +++ b/web/services/ai.service.ts @@ -12,7 +12,7 @@ const trackEvent = class AiServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createGptTask( diff --git a/web/services/analytics.service.ts b/web/services/analytics.service.ts index 0b38f8c570d..43a97abd83d 100644 --- a/web/services/analytics.service.ts +++ b/web/services/analytics.service.ts @@ -13,7 +13,7 @@ const { NEXT_PUBLIC_API_BASE_URL } = process.env; class AnalyticsServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getAnalytics(workspaceSlug: string, params: IAnalyticsParams): Promise { diff --git a/web/services/app-installations.service.ts b/web/services/app-installations.service.ts index dea6fa421cf..3e71a4facb9 100644 --- a/web/services/app-installations.service.ts +++ b/web/services/app-installations.service.ts @@ -6,7 +6,7 @@ const { NEXT_PUBLIC_API_BASE_URL } = process.env; class AppInstallationsService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async addInstallationApp(workspaceSlug: string, provider: string, data: any): Promise { diff --git a/web/services/authentication.service.ts b/web/services/authentication.service.ts index e4a33bff8a0..f98b5317119 100644 --- a/web/services/authentication.service.ts +++ b/web/services/authentication.service.ts @@ -6,7 +6,7 @@ const { NEXT_PUBLIC_API_BASE_URL } = process.env; class AuthService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async emailLogin(data: any) { diff --git a/web/services/cycles.service.ts b/web/services/cycles.service.ts index 89cd50a2fcc..1be57663c85 100644 --- a/web/services/cycles.service.ts +++ b/web/services/cycles.service.ts @@ -12,7 +12,7 @@ const trackEvent = class ProjectCycleServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createCycle( diff --git a/web/services/estimates.service.ts b/web/services/estimates.service.ts index 8b0fe25f4ec..0f303af9218 100644 --- a/web/services/estimates.service.ts +++ b/web/services/estimates.service.ts @@ -11,7 +11,7 @@ const trackEvent = class ProjectEstimateServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createEstimate( diff --git a/web/services/file.service.ts b/web/services/file.service.ts index d2f01428da4..22f225fa3b0 100644 --- a/web/services/file.service.ts +++ b/web/services/file.service.ts @@ -29,7 +29,7 @@ interface UnSplashImageUrls { class FileServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async uploadFile(workspaceSlug: string, file: FormData): Promise { diff --git a/web/services/inbox.service.ts b/web/services/inbox.service.ts index 61949c87749..3703dcdea19 100644 --- a/web/services/inbox.service.ts +++ b/web/services/inbox.service.ts @@ -19,7 +19,7 @@ import type { class InboxServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getInboxes(workspaceSlug: string, projectId: string): Promise { diff --git a/web/services/integration/csv.services.ts b/web/services/integration/csv.services.ts index f19cc4a74a9..c6f159b07a6 100644 --- a/web/services/integration/csv.services.ts +++ b/web/services/integration/csv.services.ts @@ -10,7 +10,7 @@ const trackEvent = class CSVIntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async exportCSVService( diff --git a/web/services/integration/github.service.ts b/web/services/integration/github.service.ts index 494785f04b7..25e62e3877e 100644 --- a/web/services/integration/github.service.ts +++ b/web/services/integration/github.service.ts @@ -11,7 +11,7 @@ const trackEvent = const integrationServiceType: string = "github"; class GithubIntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async listAllRepositories(workspaceSlug: string, integrationSlug: string): Promise { diff --git a/web/services/integration/index.ts b/web/services/integration/index.ts index 2b32a5bd02c..d2bccdca391 100644 --- a/web/services/integration/index.ts +++ b/web/services/integration/index.ts @@ -17,7 +17,7 @@ const trackEvent = class IntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getAppIntegrationsList(): Promise { diff --git a/web/services/integration/jira.service.ts b/web/services/integration/jira.service.ts index 8f6a9fec9c0..3d682cc773f 100644 --- a/web/services/integration/jira.service.ts +++ b/web/services/integration/jira.service.ts @@ -11,7 +11,7 @@ const trackEvent = class JiraImportedService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getJiraProjectInfo(workspaceSlug: string, params: IJiraMetadata): Promise { diff --git a/web/services/issues.service.ts b/web/services/issues.service.ts index b8875e6c5e0..b7bce8f974e 100644 --- a/web/services/issues.service.ts +++ b/web/services/issues.service.ts @@ -19,7 +19,7 @@ const trackEvent = class ProjectIssuesServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createIssues( diff --git a/web/services/modules.service.ts b/web/services/modules.service.ts index 0e3b5cfe29e..88dba374ce5 100644 --- a/web/services/modules.service.ts +++ b/web/services/modules.service.ts @@ -12,7 +12,7 @@ const trackEvent = class ProjectIssuesServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getModules(workspaceSlug: string, projectId: string): Promise { diff --git a/web/services/notifications.service.ts b/web/services/notifications.service.ts index 01c139b5154..6e9d19109e9 100644 --- a/web/services/notifications.service.ts +++ b/web/services/notifications.service.ts @@ -14,7 +14,7 @@ import type { class UserNotificationsServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getUserNotifications( diff --git a/web/services/pages.service.ts b/web/services/pages.service.ts index 72b12012e31..7a39b8eb62d 100644 --- a/web/services/pages.service.ts +++ b/web/services/pages.service.ts @@ -12,7 +12,7 @@ const trackEvent = class PageServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createPage( diff --git a/web/services/project-publish.service.ts b/web/services/project-publish.service.ts index 4ee01a94b2d..d691e46ec67 100644 --- a/web/services/project-publish.service.ts +++ b/web/services/project-publish.service.ts @@ -12,7 +12,7 @@ const trackEvent = class ProjectServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getProjectSettingsAsync( diff --git a/web/services/project.service.ts b/web/services/project.service.ts index 0c2712c5622..aac5447e4d6 100644 --- a/web/services/project.service.ts +++ b/web/services/project.service.ts @@ -23,7 +23,7 @@ const trackEvent = export class ProjectServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createProject( diff --git a/web/services/reaction.service.ts b/web/services/reaction.service.ts index 3ba8a83e453..5a71ed249a5 100644 --- a/web/services/reaction.service.ts +++ b/web/services/reaction.service.ts @@ -18,7 +18,7 @@ const trackEvent = class ReactionService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createIssueReaction( diff --git a/web/services/state.service.ts b/web/services/state.service.ts index 52481f8bb31..421e1e36381 100644 --- a/web/services/state.service.ts +++ b/web/services/state.service.ts @@ -12,7 +12,7 @@ import type { ICurrentUserResponse, IState, IStateResponse } from "types"; class ProjectStateServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createState( diff --git a/web/services/user.service.ts b/web/services/user.service.ts index 0e5def647bd..5353d47be85 100644 --- a/web/services/user.service.ts +++ b/web/services/user.service.ts @@ -19,7 +19,7 @@ const trackEvent = class UserService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } currentUserConfig() { diff --git a/web/services/views.service.ts b/web/services/views.service.ts index e1d25925ed7..0fd5e9f2438 100644 --- a/web/services/views.service.ts +++ b/web/services/views.service.ts @@ -13,7 +13,7 @@ const trackEvent = class ViewServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async createView( diff --git a/web/services/workspace.service.ts b/web/services/workspace.service.ts index 8097253e634..989f92732a0 100644 --- a/web/services/workspace.service.ts +++ b/web/services/workspace.service.ts @@ -22,7 +22,7 @@ const trackEvent = class WorkspaceService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async userWorkspaces(): Promise { From 624f2f8b7408406b6fde9e6d46dbffdcb553cac9 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 17:12:46 +0000 Subject: [PATCH 04/13] chore: added env variables for pg compose service --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 5bb240d40b1..e3c1b37be27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -85,6 +85,9 @@ services: env_file: - .env environment: + POSTGRES_USER: ${PGUSER} + POSTGRES_DB: ${PGDATABASE} + POSTGRES_PASSWORD: ${PGPASSWORD} PGDATA: /var/lib/postgresql/data plane-redis: From 9b5966e96f11ed38a9846a1117d7e9171cbf2686 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 17:16:25 +0000 Subject: [PATCH 05/13] chore: modified space app services to use accept empty string as api base --- space/services/authentication.service.ts | 2 +- space/services/file.service.ts | 2 +- space/services/issue.service.ts | 2 +- space/services/project.service.ts | 2 +- space/services/user.service.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/space/services/authentication.service.ts b/space/services/authentication.service.ts index a6f1ec90fb1..4a977daf71b 100644 --- a/space/services/authentication.service.ts +++ b/space/services/authentication.service.ts @@ -3,7 +3,7 @@ import APIService from "services/api.service"; class AuthService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async emailLogin(data: any) { diff --git a/space/services/file.service.ts b/space/services/file.service.ts index 5ef34fc760c..772d1836350 100644 --- a/space/services/file.service.ts +++ b/space/services/file.service.ts @@ -29,7 +29,7 @@ interface UnSplashImageUrls { class FileServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async uploadFile(workspaceSlug: string, file: FormData): Promise { diff --git a/space/services/issue.service.ts b/space/services/issue.service.ts index 03a94654ba2..adb8ffbc00a 100644 --- a/space/services/issue.service.ts +++ b/space/services/issue.service.ts @@ -3,7 +3,7 @@ import APIService from "services/api.service"; class IssueService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getPublicIssues(workspace_slug: string, project_slug: string, params: any): Promise { diff --git a/space/services/project.service.ts b/space/services/project.service.ts index 291a5f3230f..4b644c6c0aa 100644 --- a/space/services/project.service.ts +++ b/space/services/project.service.ts @@ -3,7 +3,7 @@ import APIService from "services/api.service"; class ProjectService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async getProjectSettings(workspace_slug: string, project_slug: string): Promise { diff --git a/space/services/user.service.ts b/space/services/user.service.ts index 9a324bb9577..0ad014226d4 100644 --- a/space/services/user.service.ts +++ b/space/services/user.service.ts @@ -3,7 +3,7 @@ import APIService from "services/api.service"; class UserService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); + super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); } async currentUser(): Promise { From 1dd88de036d1aa914cc0cd01e8c050e0a0c0b00a Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 18:16:11 +0000 Subject: [PATCH 06/13] chore: conditionally trigger web url value based on argument --- setup.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index d1e4aac3e18..82c70d0857b 100755 --- a/setup.sh +++ b/setup.sh @@ -12,8 +12,13 @@ cp ./apiserver/.env.example ./apiserver/.env # Generate the SECRET_KEY that will be used by django echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./apiserver/.env -echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env -echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env +if [ -n "$1" ] +then + echo "hello" + echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env + echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env +fi + # Generate Prompt for taking tiptap auth key echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token \e[0m \n" From 152c803c67bc60e78ccbb99c757103bc7d6bbd68 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 18:19:54 +0000 Subject: [PATCH 07/13] fix: made web to use identical host with spaces suffix on absense of Deploy URL for deploy --- web/components/project/publish-project/modal.tsx | 6 +++++- web/layouts/app-layout/app-header.tsx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/web/components/project/publish-project/modal.tsx b/web/components/project/publish-project/modal.tsx index 173a5242c32..56ed10ee001 100644 --- a/web/components/project/publish-project/modal.tsx +++ b/web/components/project/publish-project/modal.tsx @@ -63,7 +63,11 @@ export const PublishProjectModal: React.FC = observer(() => { const [isUnpublishing, setIsUnpublishing] = useState(false); const [isUpdateRequired, setIsUpdateRequired] = useState(false); - const plane_deploy_url = process.env.NEXT_PUBLIC_DEPLOY_URL ?? "http://localhost:4000"; + let plane_deploy_url = process.env.NEXT_PUBLIC_DEPLOY_URL; + + if (typeof window !== 'undefined' && !plane_deploy_url) { + plane_deploy_url= window.location.protocol + "//" + window.location.host + "/spaces"; + } const router = useRouter(); const { workspaceSlug } = router.query; diff --git a/web/layouts/app-layout/app-header.tsx b/web/layouts/app-layout/app-header.tsx index f2fbdc78c3b..27c52f654f7 100644 --- a/web/layouts/app-layout/app-header.tsx +++ b/web/layouts/app-layout/app-header.tsx @@ -17,7 +17,11 @@ type Props = { }; const { NEXT_PUBLIC_DEPLOY_URL } = process.env; -const plane_deploy_url = NEXT_PUBLIC_DEPLOY_URL ? NEXT_PUBLIC_DEPLOY_URL : "http://localhost:3001"; +let plane_deploy_url = NEXT_PUBLIC_DEPLOY_URL + +if (typeof window !== 'undefined' && !plane_deploy_url) { + plane_deploy_url= window.location.protocol + "//" + window.location.host + "/spaces"; +} const Header: React.FC = ({ breadcrumbs, left, right, setToggleSidebar, noHeader }) => { const { projectDetails } = useProjectDetails(); From 29dc96c5d73663fdfefc61dc0ef7c010f1e13ac6 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 18:20:30 +0000 Subject: [PATCH 08/13] chore: added example env for PUBLIC_DEPLOY Env --- web/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/.env.example b/web/.env.example index bae67ab08df..224a80bbfc7 100644 --- a/web/.env.example +++ b/web/.env.example @@ -23,4 +23,4 @@ NEXT_PUBLIC_SLACK_CLIENT_ID="" # For Telemetry, set it to "app.plane.so" NEXT_PUBLIC_PLAUSIBLE_DOMAIN="" # Public boards deploy URL -NEXT_PUBLIC_DEPLOY_URL="" \ No newline at end of file +NEXT_PUBLIC_DEPLOY_URL="http://localhost:3000/spaces" \ No newline at end of file From c551e8ddee08f781ddd1e54c6b7fdce9cccf645d Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Sun, 10 Sep 2023 19:03:28 +0000 Subject: [PATCH 09/13] chore: updated web dockerfile with addition as PLANE_DEPLOY Argument --- web/Dockerfile.web | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/Dockerfile.web b/web/Dockerfile.web index c86754eeec3..d9260e61d8b 100644 --- a/web/Dockerfile.web +++ b/web/Dockerfile.web @@ -14,6 +14,7 @@ FROM node:18-alpine AS installer RUN apk add --no-cache libc6-compat WORKDIR /app ARG NEXT_PUBLIC_API_BASE_URL="" +ARG NEXT_PUBLIC_DEPLOY_URL="" # First install the dependencies (as they change less often) COPY .gitignore .gitignore @@ -26,6 +27,7 @@ COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json USER root ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL RUN yarn turbo run build --filter=web @@ -46,7 +48,9 @@ COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next ARG NEXT_PUBLIC_API_BASE_URL="" +ARG NEXT_PUBLIC_DEPLOY_URL="" ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL USER root COPY start.sh /usr/local/bin/ From 8d741eb725895d3bd7bd62faa8099674124d0342 Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Tue, 12 Sep 2023 15:17:52 +0530 Subject: [PATCH 10/13] API BASE URL global update --- space/helpers/common.helper.ts | 2 ++ space/services/authentication.service.ts | 3 ++- space/services/file.service.ts | 6 ++---- space/services/issue.service.ts | 3 ++- space/services/project.service.ts | 3 ++- space/services/user.service.ts | 3 ++- web/helpers/common.helper.ts | 5 +++++ web/services/ai.service.ts | 8 +++----- web/services/analytics.service.ts | 5 ++--- web/services/app-installations.service.ts | 5 ++--- web/services/authentication.service.ts | 5 ++--- web/services/cycles.service.ts | 6 ++---- web/services/estimates.service.ts | 5 ++--- web/services/file.service.ts | 5 ++--- web/services/inbox.service.ts | 5 ++--- web/services/integration/csv.services.ts | 2 +- web/services/integration/github.service.ts | 2 +- web/services/integration/index.ts | 2 +- web/services/integration/jira.service.ts | 2 +- web/services/issues.service.ts | 5 ++--- web/services/modules.service.ts | 4 ++-- web/services/notifications.service.ts | 7 +++---- web/services/pages.service.ts | 6 ++---- web/services/project-publish.service.ts | 5 ++--- web/services/project.service.ts | 6 ++---- web/services/reaction.service.ts | 6 ++---- web/services/state.service.ts | 6 +++--- web/services/user.service.ts | 4 ++-- web/services/views.service.ts | 4 +++- web/services/workspace.service.ts | 7 +++---- 30 files changed, 64 insertions(+), 73 deletions(-) create mode 100644 space/helpers/common.helper.ts diff --git a/space/helpers/common.helper.ts b/space/helpers/common.helper.ts new file mode 100644 index 00000000000..d96c342b582 --- /dev/null +++ b/space/helpers/common.helper.ts @@ -0,0 +1,2 @@ +export const API_BASE_URL = + process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"; diff --git a/space/services/authentication.service.ts b/space/services/authentication.service.ts index 4a977daf71b..4d861994f0f 100644 --- a/space/services/authentication.service.ts +++ b/space/services/authentication.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class AuthService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async emailLogin(data: any) { diff --git a/space/services/file.service.ts b/space/services/file.service.ts index 772d1836350..d9783d29c8f 100644 --- a/space/services/file.service.ts +++ b/space/services/file.service.ts @@ -1,7 +1,5 @@ -// services import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; interface UnSplashImage { id: string; @@ -29,7 +27,7 @@ interface UnSplashImageUrls { class FileServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async uploadFile(workspaceSlug: string, file: FormData): Promise { diff --git a/space/services/issue.service.ts b/space/services/issue.service.ts index adb8ffbc00a..591db25ca04 100644 --- a/space/services/issue.service.ts +++ b/space/services/issue.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class IssueService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getPublicIssues(workspace_slug: string, project_slug: string, params: any): Promise { diff --git a/space/services/project.service.ts b/space/services/project.service.ts index 4b644c6c0aa..0d6eca951b4 100644 --- a/space/services/project.service.ts +++ b/space/services/project.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class ProjectService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getProjectSettings(workspace_slug: string, project_slug: string): Promise { diff --git a/space/services/user.service.ts b/space/services/user.service.ts index 0ad014226d4..21e9f941e59 100644 --- a/space/services/user.service.ts +++ b/space/services/user.service.ts @@ -1,9 +1,10 @@ // services import APIService from "services/api.service"; +import { API_BASE_URL } from "helpers/common.helper"; class UserService extends APIService { constructor() { - super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async currentUser(): Promise { diff --git a/web/helpers/common.helper.ts b/web/helpers/common.helper.ts index 4220a7174ce..0829863c9fe 100644 --- a/web/helpers/common.helper.ts +++ b/web/helpers/common.helper.ts @@ -16,3 +16,8 @@ export const debounce = (func: any, wait: number, immediate: boolean = false) => if (callNow) func(...args); }; }; + +export const API_BASE_URL = + process.env.NEXT_PUBLIC_API_BASE_URL !== undefined + ? process.env.NEXT_PUBLIC_API_BASE_URL + : "http://localhost:8000"; diff --git a/web/services/ai.service.ts b/web/services/ai.service.ts index 1ea31335a62..33b59f3df24 100644 --- a/web/services/ai.service.ts +++ b/web/services/ai.service.ts @@ -1,18 +1,16 @@ -// services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import { ICurrentUserResponse, IGptResponse } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +// helpers +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class AiServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createGptTask( diff --git a/web/services/analytics.service.ts b/web/services/analytics.service.ts index 43a97abd83d..66b6569e807 100644 --- a/web/services/analytics.service.ts +++ b/web/services/analytics.service.ts @@ -8,12 +8,11 @@ import { IExportAnalyticsFormData, ISaveAnalyticsFormData, } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; class AnalyticsServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getAnalytics(workspaceSlug: string, params: IAnalyticsParams): Promise { diff --git a/web/services/app-installations.service.ts b/web/services/app-installations.service.ts index 3e71a4facb9..8b18cddfcae 100644 --- a/web/services/app-installations.service.ts +++ b/web/services/app-installations.service.ts @@ -1,12 +1,11 @@ // services import axios from "axios"; import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; class AppInstallationsService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async addInstallationApp(workspaceSlug: string, provider: string, data: any): Promise { diff --git a/web/services/authentication.service.ts b/web/services/authentication.service.ts index f98b5317119..58eaa2aff8f 100644 --- a/web/services/authentication.service.ts +++ b/web/services/authentication.service.ts @@ -1,12 +1,11 @@ // services import APIService from "services/api.service"; import { ICurrentUserResponse } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; class AuthService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async emailLogin(data: any) { diff --git a/web/services/cycles.service.ts b/web/services/cycles.service.ts index 1be57663c85..e0e42c68741 100644 --- a/web/services/cycles.service.ts +++ b/web/services/cycles.service.ts @@ -1,18 +1,16 @@ // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import type { CycleDateCheckData, ICurrentUserResponse, ICycle, IIssue } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectCycleServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createCycle( diff --git a/web/services/estimates.service.ts b/web/services/estimates.service.ts index 0f303af9218..eaa49e57ccb 100644 --- a/web/services/estimates.service.ts +++ b/web/services/estimates.service.ts @@ -3,15 +3,14 @@ import APIService from "services/api.service"; // types import type { ICurrentUserResponse, IEstimate, IEstimateFormData } from "types"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectEstimateServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createEstimate( diff --git a/web/services/file.service.ts b/web/services/file.service.ts index 22f225fa3b0..cbed73fc897 100644 --- a/web/services/file.service.ts +++ b/web/services/file.service.ts @@ -1,7 +1,6 @@ // services import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; interface UnSplashImage { id: string; @@ -29,7 +28,7 @@ interface UnSplashImageUrls { class FileServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async uploadFile(workspaceSlug: string, file: FormData): Promise { diff --git a/web/services/inbox.service.ts b/web/services/inbox.service.ts index 3703dcdea19..16eed288ec2 100644 --- a/web/services/inbox.service.ts +++ b/web/services/inbox.service.ts @@ -1,7 +1,6 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; @@ -19,7 +18,7 @@ import type { class InboxServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getInboxes(workspaceSlug: string, projectId: string): Promise { diff --git a/web/services/integration/csv.services.ts b/web/services/integration/csv.services.ts index c6f159b07a6..292ccde2dbc 100644 --- a/web/services/integration/csv.services.ts +++ b/web/services/integration/csv.services.ts @@ -10,7 +10,7 @@ const trackEvent = class CSVIntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async exportCSVService( diff --git a/web/services/integration/github.service.ts b/web/services/integration/github.service.ts index 25e62e3877e..0394df254b2 100644 --- a/web/services/integration/github.service.ts +++ b/web/services/integration/github.service.ts @@ -11,7 +11,7 @@ const trackEvent = const integrationServiceType: string = "github"; class GithubIntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async listAllRepositories(workspaceSlug: string, integrationSlug: string): Promise { diff --git a/web/services/integration/index.ts b/web/services/integration/index.ts index d2bccdca391..78284992a77 100644 --- a/web/services/integration/index.ts +++ b/web/services/integration/index.ts @@ -17,7 +17,7 @@ const trackEvent = class IntegrationService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getAppIntegrationsList(): Promise { diff --git a/web/services/integration/jira.service.ts b/web/services/integration/jira.service.ts index 3d682cc773f..9399946e528 100644 --- a/web/services/integration/jira.service.ts +++ b/web/services/integration/jira.service.ts @@ -11,7 +11,7 @@ const trackEvent = class JiraImportedService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getJiraProjectInfo(workspaceSlug: string, params: IJiraMetadata): Promise { diff --git a/web/services/issues.service.ts b/web/services/issues.service.ts index b7bce8f974e..6a642506744 100644 --- a/web/services/issues.service.ts +++ b/web/services/issues.service.ts @@ -11,15 +11,14 @@ import type { IIssueViewOptions, ISubIssueResponse, } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectIssuesServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createIssues( diff --git a/web/services/modules.service.ts b/web/services/modules.service.ts index 88dba374ce5..dcac98d501f 100644 --- a/web/services/modules.service.ts +++ b/web/services/modules.service.ts @@ -1,9 +1,9 @@ // services import APIService from "services/api.service"; import trackEventServices from "./track-event.service"; - // types import type { IIssueViewOptions, IModule, IIssue, ICurrentUserResponse } from "types"; +import { API_BASE_URL } from "helpers/common.helper"; const { NEXT_PUBLIC_API_BASE_URL } = process.env; @@ -12,7 +12,7 @@ const trackEvent = class ProjectIssuesServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getModules(workspaceSlug: string, projectId: string): Promise { diff --git a/web/services/notifications.service.ts b/web/services/notifications.service.ts index 6e9d19109e9..8ff64e91567 100644 --- a/web/services/notifications.service.ts +++ b/web/services/notifications.service.ts @@ -1,8 +1,5 @@ // services import APIService from "services/api.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - // types import type { IUserNotification, @@ -11,10 +8,12 @@ import type { PaginatedUserNotification, IMarkAllAsReadPayload, } from "types"; +// helpers +import { API_BASE_URL } from "helpers/common.helper"; class UserNotificationsServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getUserNotifications( diff --git a/web/services/pages.service.ts b/web/services/pages.service.ts index 7a39b8eb62d..b9dc580f318 100644 --- a/web/services/pages.service.ts +++ b/web/services/pages.service.ts @@ -1,18 +1,16 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import { IPage, IPageBlock, RecentPagesResponse, IIssue, ICurrentUserResponse } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class PageServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createPage( diff --git a/web/services/project-publish.service.ts b/web/services/project-publish.service.ts index d691e46ec67..05555bd2913 100644 --- a/web/services/project-publish.service.ts +++ b/web/services/project-publish.service.ts @@ -1,3 +1,4 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; @@ -5,14 +6,12 @@ import trackEventServices from "services/track-event.service"; import { ICurrentUserResponse } from "types"; import { IProjectPublishSettings } from "store/project-publish"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ProjectServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async getProjectSettingsAsync( diff --git a/web/services/project.service.ts b/web/services/project.service.ts index aac5447e4d6..54826c90055 100644 --- a/web/services/project.service.ts +++ b/web/services/project.service.ts @@ -1,7 +1,7 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import type { GithubRepositoriesResponse, @@ -16,14 +16,12 @@ import type { TProjectIssuesSearchParams, } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; export class ProjectServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createProject( diff --git a/web/services/reaction.service.ts b/web/services/reaction.service.ts index 5a71ed249a5..35dc915a177 100644 --- a/web/services/reaction.service.ts +++ b/web/services/reaction.service.ts @@ -1,7 +1,7 @@ +import { API_BASE_URL } from "helpers/common.helper"; // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - // types import type { ICurrentUserResponse, @@ -11,14 +11,12 @@ import type { IssueCommentReactionForm, } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class ReactionService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createIssueReaction( diff --git a/web/services/state.service.ts b/web/services/state.service.ts index 421e1e36381..a97753d6d6e 100644 --- a/web/services/state.service.ts +++ b/web/services/state.service.ts @@ -1,8 +1,8 @@ // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +// helpers +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; @@ -12,7 +12,7 @@ import type { ICurrentUserResponse, IState, IStateResponse } from "types"; class ProjectStateServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createState( diff --git a/web/services/user.service.ts b/web/services/user.service.ts index 5353d47be85..6a852334872 100644 --- a/web/services/user.service.ts +++ b/web/services/user.service.ts @@ -12,14 +12,14 @@ import type { IUserWorkspaceDashboard, } from "types"; -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; class UserService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } currentUserConfig() { diff --git a/web/services/views.service.ts b/web/services/views.service.ts index 0fd5e9f2438..a684e41ff18 100644 --- a/web/services/views.service.ts +++ b/web/services/views.service.ts @@ -6,6 +6,8 @@ import { ICurrentUserResponse } from "types"; // types import { IView } from "types/views"; +import { API_BASE_URL } from "helpers/common.helper"; + const { NEXT_PUBLIC_API_BASE_URL } = process.env; const trackEvent = @@ -13,7 +15,7 @@ const trackEvent = class ViewServices extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async createView( diff --git a/web/services/workspace.service.ts b/web/services/workspace.service.ts index 989f92732a0..0539cdf8c2e 100644 --- a/web/services/workspace.service.ts +++ b/web/services/workspace.service.ts @@ -1,9 +1,8 @@ // services import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; - +// helpers +import { API_BASE_URL } from "helpers/common.helper"; // types import { IWorkspace, @@ -22,7 +21,7 @@ const trackEvent = class WorkspaceService extends APIService { constructor() { - super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000"); + super(API_BASE_URL); } async userWorkspaces(): Promise { From d3d1c669a1b3f72651e7a2324fc1c40726032fae Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Tue, 12 Sep 2023 15:24:57 +0530 Subject: [PATCH 11/13] API BASE URL replace with api server --- web/lib/auth.ts | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/web/lib/auth.ts b/web/lib/auth.ts index eb72c0f183f..56cfab9ae78 100644 --- a/web/lib/auth.ts +++ b/web/lib/auth.ts @@ -2,6 +2,8 @@ import { convertCookieStringToObject } from "./cookie"; // types import type { IProjectMember, IUser, IWorkspace, IWorkspaceMember } from "types"; +// helper +import { API_BASE_URL } from "helpers/common.helper"; export const requiredAuth = async (cookie?: string) => { const cookies = convertCookieStringToObject(cookie); @@ -9,12 +11,10 @@ export const requiredAuth = async (cookie?: string) => { if (!token) return null; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; - let user: IUser | null = null; try { - const data = await fetch(`${baseUrl}/api/users/me/`, { + const data = await fetch(`${API_BASE_URL}/api/users/me/`, { method: "GET", headers: { "Content-Type": "application/json", @@ -41,13 +41,11 @@ export const requiredAdmin = async (workspaceSlug: string, projectId: string, co const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; - let memberDetail: IProjectMember | null = null; try { const data = await fetch( - `${baseUrl}/api/workspaces/${workspaceSlug}/projects/${projectId}/project-members/me/`, + `${API_BASE_URL}/api/workspaces/${workspaceSlug}/projects/${projectId}/project-members/me/`, { method: "GET", headers: { @@ -75,17 +73,18 @@ export const requiredWorkspaceAdmin = async (workspaceSlug: string, cookie?: str const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; - let memberDetail: IWorkspaceMember | null = null; try { - const data = await fetch(`${baseUrl}/api/workspaces/${workspaceSlug}/workspace-members/me/`, { - method: "GET", - headers: { - Authorization: `Bearer ${token}`, - }, - }) + const data = await fetch( + `${API_BASE_URL}/api/workspaces/${workspaceSlug}/workspace-members/me/`, + { + method: "GET", + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) .then((res) => res.json()) .then((data) => data); @@ -119,13 +118,11 @@ export const homePageRedirect = async (cookie?: string) => { let workspaces: IWorkspace[] = []; - const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so"; - const cookies = convertCookieStringToObject(cookie); const token = cookies?.accessToken; try { - const data = await fetch(`${baseUrl}/api/users/me/workspaces/`, { + const data = await fetch(`${API_BASE_URL}/api/users/me/workspaces/`, { method: "GET", headers: { "Content-Type": "application/json", @@ -166,7 +163,7 @@ export const homePageRedirect = async (cookie?: string) => { }; } - const invitations = await fetch(`${baseUrl}/api/users/me/invitations/workspaces/`, { + const invitations = await fetch(`${API_BASE_URL}/api/users/me/invitations/workspaces/`, { method: "GET", headers: { "Content-Type": "application/json", From 796cb4b1ffa9b99951bd2b26f560d5fac9cb23ff Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Tue, 12 Sep 2023 17:58:30 +0530 Subject: [PATCH 12/13] api base url fixes --- web/services/integration/csv.services.ts | 4 +--- web/services/integration/github.service.ts | 1 + web/services/integration/index.ts | 3 +-- web/services/integration/jira.service.ts | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/web/services/integration/csv.services.ts b/web/services/integration/csv.services.ts index 292ccde2dbc..0b53f7778a4 100644 --- a/web/services/integration/csv.services.ts +++ b/web/services/integration/csv.services.ts @@ -1,9 +1,7 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - import { ICurrentUserResponse } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; diff --git a/web/services/integration/github.service.ts b/web/services/integration/github.service.ts index 0394df254b2..58aa12318a7 100644 --- a/web/services/integration/github.service.ts +++ b/web/services/integration/github.service.ts @@ -1,5 +1,6 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; +import { API_BASE_URL } from "helpers/common.helper"; import { ICurrentUserResponse, IGithubRepoInfo, IGithubServiceImportFormData } from "types"; diff --git a/web/services/integration/index.ts b/web/services/integration/index.ts index 78284992a77..b1bbefda836 100644 --- a/web/services/integration/index.ts +++ b/web/services/integration/index.ts @@ -9,8 +9,7 @@ import { IWorkspaceIntegration, IExportServiceResponse, } from "types"; - -const { NEXT_PUBLIC_API_BASE_URL } = process.env; +import { API_BASE_URL } from "helpers/common.helper"; const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; diff --git a/web/services/integration/jira.service.ts b/web/services/integration/jira.service.ts index 9399946e528..d4620f3ff0c 100644 --- a/web/services/integration/jira.service.ts +++ b/web/services/integration/jira.service.ts @@ -1,6 +1,6 @@ import APIService from "services/api.service"; import trackEventServices from "services/track-event.service"; - +import { API_BASE_URL } from "helpers/common.helper"; // types import { IJiraMetadata, IJiraResponse, IJiraImporterForm, ICurrentUserResponse } from "types"; From 56cb5647935b4c54b5ae0aa94525cd25f8b0973d Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Tue, 12 Sep 2023 18:05:58 +0530 Subject: [PATCH 13/13] typo fixes --- setup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.sh b/setup.sh index 82c70d0857b..940fb8b4d22 100755 --- a/setup.sh +++ b/setup.sh @@ -14,7 +14,6 @@ echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./api if [ -n "$1" ] then - echo "hello" echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env fi