From 6e98497389847927b5e873ebe5ac82d8438f0cde Mon Sep 17 00:00:00 2001 From: yingying Date: Wed, 8 Jan 2025 11:45:19 +0800 Subject: [PATCH] chore: optimize the next.config configuration and remove unnecessary environment variable files --- client/.env.example | 2 -- client/.env.local.example | 7 +++-- client/next.config.js | 47 +++++++++++------------------ docs/guides/self_hosted_local.md | 6 ++-- docs/guides/self_hosted_local_cn.md | 4 +-- server/.env.example | 46 ---------------------------- 6 files changed, 27 insertions(+), 85 deletions(-) delete mode 100644 client/.env.example delete mode 100644 server/.env.example diff --git a/client/.env.example b/client/.env.example deleted file mode 100644 index 8d275b43..00000000 --- a/client/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -SELF_PATH=/client/ -NEXT_PUBLIC_API_DOMAIN=http://127.0.0.1:8000 diff --git a/client/.env.local.example b/client/.env.local.example index e61d3ff9..d4b93395 100644 --- a/client/.env.local.example +++ b/client/.env.local.example @@ -1,2 +1,5 @@ -SELF_PATH=/client/ -NEXT_PUBLIC_API_DOMAIN=http://localhost:8001 \ No newline at end of file +NODE_ENV="development" + +NEXT_PUBLIC_API_DOMAIN="http://127.0.0.1:8000" + +NEXT_STANDALONE="true" diff --git a/client/next.config.js b/client/next.config.js index fcc9a4ac..5a492ea6 100644 --- a/client/next.config.js +++ b/client/next.config.js @@ -1,51 +1,38 @@ -// const withBundleAnalyzer = require('@next/bundle-analyzer')({ -// enabled: process.env.ANALYZE === 'true', -// }) -// module.exports = withBundleAnalyzer({}) const { withSentryConfig } = require("@sentry/nextjs"); - const nextConfig = { - ...process.env.NEXT_STANDALONE ? { output: "standalone" } :{}, - webpack: (config, { dev}) => { + ...process.env.NEXT_STANDALONE ? { output: "standalone" } : {}, // Standalone configuration + webpack: (config, { dev }) => { config.resolve.fallback = { http: false, https: false, net: false, tls: false }; if (dev) { config.watchOptions = { followSymlinks: true, - } + }; config.snapshot.managedPaths = []; } + + // Add markdown loader + config.module.rules.push({ + test: /\.md$/, + use: 'raw-loader', + }); + return config; - } + }, }; -// Make sure adding Sentry options is the last code to run before exporting -module.exports = withSentryConfig(nextConfig, { + +const sentryOptions = { org: "petercat", project: "petercat", - - // An auth token is required for uploading source maps. - authToken: process.env.SENTRY_AUTH_TOKEN, - - silent: false, // Can be used to suppress logs - + authToken: process.env.SENTRY_AUTH_TOKEN, + silent: false, hideSourceMaps: true, - sourcemaps: { disable: true, }, -}); - -module.exports = { - output: "standalone", - webpack: (config) => { - config.module.rules.push({ - test: /\.md$/, - use: 'raw-loader', - }); - - return config; - }, }; + +module.exports = withSentryConfig(nextConfig, sentryOptions); diff --git a/docs/guides/self_hosted_local.md b/docs/guides/self_hosted_local.md index 345b7495..d8cd1864 100644 --- a/docs/guides/self_hosted_local.md +++ b/docs/guides/self_hosted_local.md @@ -38,10 +38,10 @@ docker compose pull docker compose up -d ``` -### Step 4: Copy the `.env.example` Files +### Step 4: Copy the `.env.local.example` Files Copy the client environment configuration example file: ```bash -cp client/.env.local.example client/.env +cp client/.env.local.example client/.env.local ``` Copy the server environment configuration example file: @@ -104,4 +104,4 @@ yarn run client ``` Verify the client service by opening `http://127.0.0.1:3000` in your browser. -``` \ No newline at end of file +``` diff --git a/docs/guides/self_hosted_local_cn.md b/docs/guides/self_hosted_local_cn.md index 322ef118..b4e68174 100644 --- a/docs/guides/self_hosted_local_cn.md +++ b/docs/guides/self_hosted_local_cn.md @@ -37,10 +37,10 @@ docker compose pull docker compose up -d ``` -### 第四步:复制 `.env.example` 文件 +### 第四步:复制 `.env.local.example` 文件 复制客户端环境配置示例文件: ```bash -cp client/.env.local.example client/.env +cp client/.env.local.example client/.env.local ``` 复制服务器环境配置示例文件: diff --git a/server/.env.example b/server/.env.example deleted file mode 100644 index b5e86f1f..00000000 --- a/server/.env.example +++ /dev/null @@ -1,46 +0,0 @@ -# App Base Configures -API_URL=http://localhost:8000 -WEB_URL=http://localhost:3000 -# OPTIONAL - standalong static url if required -STATIC_URL=STATIC_URL - -FASTAPI_SECRET_KEY=fastapi_secret_key -# `Project URL` field of https://supabase.com/dashboard/project/_/settings/database -SUPABASE_URL=${SUPABASE_PUBLIC_URL} -# `Project API keys`: `anon public` field of https://supabase.com/dashboard/project/_/settings/database -SUPABASE_SERVICE_KEY=${SERVICE_ROLE_KEY} - -SUPABASE_PASSWORD=aABCDEFG -# OpenAI API KEY -OPENAI_API_KEY=sk-xxxx -# OPTIONAL - Gemini -GEMINI_API_KEY=gemini_api_key -# Tavily Api Key -TAVILY_API_KEY=tavily_api_key - -# OPTIONAL - Github Apps Configures -X_GITHUB_APP_ID=github_app_id -X_GITHUB_APPS_CLIENT_ID=github_apps_client_id -X_GITHUB_APPS_CLIENT_SECRET=github_apps_client_secret - -PETERCAT_AUTH0_ENABLED=False -# OPTIONAL - Local Authorization Configures - -PETERCAT_LOCAL_UID="petercat|001" -PETERCAT_LOCAL_UNAME="petercat" - -# OPTIONAL - AUTH0 Configures - -API_IDENTIFIER=api_identifier -AUTH0_DOMAIN=auth0_domain -AUTH0_CLIENT_ID=auth0_client_id -AUTH0_CLIENT_SECRET=auth0_client_secret - -# OPTIONAL - AWS Configures -SQS_QUEUE_URL=https://sqs.ap-northeast-1.amazonaws.com/{your_aws_user}/{your_aws_sqs_message} -X_GITHUB_SECRET_NAME="prod/githubapp/petercat/pem" -STATIC_SECRET_NAME="prod/petercat/static" -LLM_TOKEN_SECRET_NAME="prod/petercat/llm" -LLM_TOKEN_PUBLIC_NAME="petercat/prod/llm/pub" -STATIC_KEYPAIR_ID="xxxxxx" -S3_TEMP_BUCKET_NAME=S3_TEMP_BUCKET_NAME