From ba4a2fc9d29e71f7019dae9cbb6027f3756347a6 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Wed, 12 Apr 2023 13:26:42 +0800 Subject: [PATCH] fix: API server address in electron (#1888) Co-authored-by: himself65 --- .github/workflows/release-desktop-app.yml | 2 +- apps/web/.env.local.template | 2 +- apps/web/next.config.mjs | 7 ++++--- package.json | 4 ++-- packages/cli/src/dev.mjs | 2 +- playwright.config.ts | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-desktop-app.yml b/.github/workflows/release-desktop-app.yml index 02307e2b63..90cc6f1920 100644 --- a/.github/workflows/release-desktop-app.yml +++ b/.github/workflows/release-desktop-app.yml @@ -42,7 +42,7 @@ env: NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} AFFINE_GOOGLE_CLIENT_ID: ${{ secrets.AFFINE_GOOGLE_CLIENT_ID }} AFFINE_GOOGLE_CLIENT_SECRET: ${{ secrets.AFFINE_GOOGLE_CLIENT_SECRET }} - NODE_API_SERVER: 'https://app.affine.pro' + API_SERVER_PROFILE: prod jobs: make-macos: diff --git a/apps/web/.env.local.template b/apps/web/.env.local.template index f8fad6de4d..19915e2e9d 100644 --- a/apps/web/.env.local.template +++ b/apps/web/.env.local.template @@ -8,7 +8,7 @@ NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID= # absolute path to the block suite directory LOCAL_BLOCK_SUITE= # see next.config.js -NODE_API_SERVER= +API_SERVER_PROFILE= # save workspace to idb ENABLE_IDB_PROVIDER=1 PREFETCH_WORKSPACE=1 diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index 6620c4f284..e4ed29dfc8 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -26,7 +26,7 @@ const profileTarget = { dev: '100.84.105.99:11001', test: '100.84.105.99:11001', stage: '', - pro: 'http://pathfinder.affine.pro', + prod: 'http://app.affine.pro', local: '127.0.0.1:3000', }; @@ -89,7 +89,8 @@ const nextConfig = { gitVersion: getGitVersion(), hash: getCommitHash(), serverAPI: - profileTarget[process.env.NODE_API_SERVER || 'dev'] ?? profileTarget.dev, + profileTarget[process.env.API_SERVER_PROFILE || 'dev'] ?? + profileTarget.dev, editorVersion: require('./package.json').dependencies['@blocksuite/editor'], ...preset, }, @@ -117,7 +118,7 @@ const nextConfig = { }, rewrites: async () => { const [profile, target, desc] = getRedirectConfig( - process.env.NODE_API_SERVER + process.env.API_SERVER_PROFILE ); console.info(`API request proxy to [${desc} Server]: ` + target); return profile; diff --git a/package.json b/package.json index 5a94e6301e..1c9b69d2ea 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ ], "scripts": { "dev": "dev-web", - "dev:ac": "NODE_API_SERVER=ac yarn workspace @affine/web dev", - "dev:local": "NODE_API_SERVER=local yarn workspace @affine/web dev", + "dev:ac": "API_SERVER_PROFILE=ac yarn workspace @affine/web dev", + "dev:local": "API_SERVER_PROFILE=local yarn workspace @affine/web dev", "dev:app": "yarn workspace @affine/electron dev:app", "build": "yarn workspace @affine/web build", "build:client": "yarn workspace @affine/client-app build:app", diff --git a/packages/cli/src/dev.mjs b/packages/cli/src/dev.mjs index f7d05f95bd..4309f9ec3a 100755 --- a/packages/cli/src/dev.mjs +++ b/packages/cli/src/dev.mjs @@ -50,7 +50,7 @@ const dev = await p.group( ); const env = { - NODE_API_SERVER: dev.server, + API_SERVER_PROFILE: dev.server, PATH: process.env.PATH, NODE_ENV: 'development', }; diff --git a/playwright.config.ts b/playwright.config.ts index a5278de593..e99f2f5ff4 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -76,7 +76,7 @@ const config: PlaywrightTestConfig = { ENABLE_DEBUG_PAGE: '1', ENABLE_SUBPAGE: '1', ENABLE_CHANGELOG: '1', - NODE_API_SERVER: 'local', + API_SERVER_PROFILE: 'local', }, }, ],