3v324v23 commited on
Commit
fa21c94
·
1 Parent(s): e3725d2

fix: stripe initialization crash and port collision

Browse files
Files changed (3) hide show
  1. .env +1 -1
  2. api/services/stripe.service.ts +6 -1
  3. vite.config.ts +1 -1
.env CHANGED
@@ -4,5 +4,5 @@ OPENAI_API_BASE_URL=https://api.siliconflow.cn/v1
4
  MODEL_NAME=Qwen/Qwen2.5-7B-Instruct
5
 
6
  # 部署配置
7
- PORT=3000
8
  NODE_ENV=development
 
4
  MODEL_NAME=Qwen/Qwen2.5-7B-Instruct
5
 
6
  # 部署配置
7
+ PORT=7860
8
  NODE_ENV=development
api/services/stripe.service.ts CHANGED
@@ -4,10 +4,15 @@ import { supabase } from '../lib/supabase.js';
4
 
5
  dotenv.config();
6
 
7
- const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || '', {
 
8
  apiVersion: '2024-11-20.acacia' as any,
9
  });
10
 
 
 
 
 
11
  export class StripeService {
12
  /**
13
  * 为用户创建 Stripe 客户
 
4
 
5
  dotenv.config();
6
 
7
+ const STRIPE_KEY = process.env.STRIPE_SECRET_KEY || 'sk_test_mock_key_for_demo';
8
+ const stripe = new Stripe(STRIPE_KEY, {
9
  apiVersion: '2024-11-20.acacia' as any,
10
  });
11
 
12
+ if (!process.env.STRIPE_SECRET_KEY) {
13
+ console.warn('[Stripe] 未检测到 STRIPE_SECRET_KEY,支付功能将处于模拟模式。');
14
+ }
15
+
16
  export class StripeService {
17
  /**
18
  * 为用户创建 Stripe 客户
vite.config.ts CHANGED
@@ -38,7 +38,7 @@ export default defineConfig({
38
  server: {
39
  proxy: {
40
  '/api': {
41
- target: 'http://localhost:3001',
42
  changeOrigin: true,
43
  },
44
  },
 
38
  server: {
39
  proxy: {
40
  '/api': {
41
+ target: 'http://localhost:7860',
42
  changeOrigin: true,
43
  },
44
  },