Skip to content

Commit bb3a577

Browse files
committed
fix subdomain issue
1 parent 6b68004 commit bb3a577

File tree

6 files changed

+12
-17
lines changed

6 files changed

+12
-17
lines changed

internal/interfaces/api/form/content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
MaxMemory = 8 << 20
10+
MaxMemory = 32 << 20
1111
)
1212

1313
type Content struct {

internal/interfaces/api/handler/handlecontent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (s *Handler) getContent(res http.ResponseWriter, req *http.Request) {
201201
}
202202

203203
func (s *Handler) postContent(res http.ResponseWriter, req *http.Request) {
204-
err := req.ParseMultipartForm(apiFrom.MaxMemory) // maxMemory 4MB
204+
err := req.ParseMultipartForm(apiFrom.MaxMemory)
205205
if err != nil {
206206
s.log.Errorf("Error parsing multipart form: %v", err)
207207
res.WriteHeader(http.StatusInternalServerError)

internal/interfaces/api/handler/handledomain.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"strings"
99

1010
"github.com/mdfriday/hugoverse/internal/application"
11-
contentVO "github.com/mdfriday/hugoverse/internal/domain/content/valueobject"
1211
apiFrom "github.com/mdfriday/hugoverse/internal/interfaces/api/form"
1312
"github.com/mdfriday/hugoverse/pkg/timestamp"
1413
)
@@ -236,21 +235,17 @@ func (s *Handler) UpdateSubDomainHandler(res http.ResponseWriter, req *http.Requ
236235

237236
// 2. 更新 SubDomain 记录
238237
now := timestamp.CurrentTimeMillis()
239-
newSd := &contentVO.SubDomain{
240-
License: license.LicenseKey,
241-
Sub: newSubdomain,
242-
Item: contentVO.Item{
243-
Timestamp: now,
244-
Updated: now,
245-
Namespace: "SubDomain",
246-
},
247-
}
238+
oldSd.Sub = newSubdomain
239+
oldSd.Timestamp = now
240+
oldSd.Updated = now
248241

249242
// 创建新的 SubDomain 记录
250-
if _, err := s.contentApp.CreateSubDomain(newSd); err != nil {
243+
if err := s.contentApp.UpdateSubDomain(oldSd); err != nil {
251244
s.log.Errorf("Failed to create new subdomain record: %v", err)
252245
// 回滚:恢复旧的 Caddy route
253-
s.caddyClient.AddStaticSite(oldFullDomain, sitePath)
246+
if err := s.caddyClient.AddStaticSite(oldFullDomain, sitePath); err != nil {
247+
s.log.Errorf("Failed to rollback old Caddy route: %v", err)
248+
}
254249
s.jsonError(res, "Failed to update subdomain: "+err.Error(), http.StatusInternalServerError)
255250
return
256251
}

internal/interfaces/api/handler/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func New(log loggers.Logger, db *database.Database,
7171

7272
caddyClient := caddy.NewClient(&caddy.Config{
7373
ServerIP: adminApp.ServerIP(),
74-
CoreDomain: adminApp.Domain(),
74+
CoreDomain: adminApp.RootDomain(),
7575
})
7676

7777
// 创建基本Handler结构

internal/interfaces/cli/vercurr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package cli
33
var CurrentVersion = Version{
44
Major: 0,
55
Minor: 2,
6-
PatchLevel: 16,
6+
PatchLevel: 17,
77
Suffix: "",
88
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.2.16",
2+
"version": "0.2.17",
33
"name": "Hugoverse",
44
"description": "Headless CMS for Hugo",
55
"author": "sunwei",

0 commit comments

Comments
 (0)