新增跨域

This commit is contained in:
zhx 2026-05-26 16:20:17 +08:00
parent e921b7912c
commit 08f7879a06
5 changed files with 6 additions and 2 deletions

View File

@ -17,6 +17,7 @@ cors:
- "http://127.0.0.1:5173"
- "https://global-interaction.com"
- "https://www.global-interaction.com"
- "https://h5.global-interaction.com"
- "https://api.global-interaction.com"
allowed_methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
allowed_headers:

View File

@ -14,6 +14,7 @@ cors:
allowed_origins:
- "https://global-interaction.com"
- "https://www.global-interaction.com"
- "https://h5.global-interaction.com"
- "https://api.global-interaction.com"
allowed_methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
allowed_headers:

View File

@ -17,6 +17,7 @@ cors:
- "http://127.0.0.1:5173"
- "https://global-interaction.com"
- "https://www.global-interaction.com"
- "https://h5.global-interaction.com"
- "https://api.global-interaction.com"
allowed_methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
allowed_headers:

View File

@ -244,6 +244,7 @@ func Default() Config {
"http://127.0.0.1:5173",
"https://global-interaction.com",
"https://www.global-interaction.com",
"https://h5.global-interaction.com",
"https://api.global-interaction.com",
},
AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},

View File

@ -22,7 +22,7 @@ func TestLoad(t *testing.T) {
if cfg.RoomServiceAddr != "127.0.0.1:13001" {
t.Fatalf("unexpected room addr: %s", cfg.RoomServiceAddr)
}
if !cfg.CORS.Enabled || !containsString(cfg.CORS.AllowedOrigins, "https://global-interaction.com") || !containsString(cfg.CORS.AllowedHeaders, "X-App-Code") {
if !cfg.CORS.Enabled || !containsString(cfg.CORS.AllowedOrigins, "https://h5.global-interaction.com") || !containsString(cfg.CORS.AllowedHeaders, "X-App-Code") {
t.Fatalf("unexpected cors config: %+v", cfg.CORS)
}
if cfg.GRPCClient.DefaultTimeout != 5*time.Second || cfg.GRPCClient.RetryMaxAttempts != 2 || len(cfg.GRPCClient.RetryableStatusCodes) != 1 || cfg.GRPCClient.RetryableStatusCodes[0] != "UNAVAILABLE" {
@ -67,7 +67,7 @@ func TestLoadTencentExample(t *testing.T) {
if cfg.TencentIM.CallbackURL == "" {
t.Fatalf("callback_url template must be present")
}
if !cfg.CORS.Enabled || !containsString(cfg.CORS.AllowedOrigins, "https://global-interaction.com") || cfg.CORS.MaxAgeSec != 600 {
if !cfg.CORS.Enabled || !containsString(cfg.CORS.AllowedOrigins, "https://h5.global-interaction.com") || cfg.CORS.MaxAgeSec != 600 {
t.Fatalf("tencent cors template must be explicit: %+v", cfg.CORS)
}
if cfg.AppConfig.MySQLDSN == "" || !strings.Contains(cfg.AppConfig.MySQLDSN, "hyapp_admin") {