Skip to content

Commit 5b911b6

Browse files
committed
fix: frontend request error
1 parent c9cfb30 commit 5b911b6

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

config.yaml.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ site:
3737
signature: "鼠鼠是穿越者..." # 个性签名
3838
about: "鼠鼠是一个喜欢折腾的程序员..." # 关于我
3939
avatarPath: avatar.jpg # 头像路径
40+
server: https://123c.com # 远程路径,不需要填写端口号
4041
comment_enabled: false # 是否启用评论功能
4142
icp: 粤ICP备123456789号 # 备案号(可选)

config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"mkBlog/models"
77
"os"
88
"path"
9+
"strings"
910

1011
"go.yaml.in/yaml/v3"
1112
)
@@ -94,7 +95,10 @@ func Init() {
9495
return
9596
}
9697

97-
Cfg.Site.Server = fmt.Sprintf("http://localhost:%d", Cfg.Server.Port)
98+
if !strings.Contains(Cfg.Site.Server, ":") {
99+
Cfg.Site.Server = fmt.Sprintf("%s:%d", Cfg.Site.Server, Cfg.Server.Port)
100+
}
101+
98102
Cfg.Site.DevMode = Cfg.Server.Devmode
99103

100104
if Cfg.TLS.Enabled {

models/article.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import "time"
55
type ArticleSummary struct {
66
Title string `json:"title" gorm:"primaryKey"`
77
UpdateAt *time.Time `json:"updateAt" gorm:"autoUpdateTime;"`
8-
Category string `json:"category" gorm:"type:VARCHAR(255)"`
8+
Category string `json:"category" gorm:"type:varchar(255)"`
99
Summary string `json:"summary" gorm:"type:TEXT"`
1010
}
1111

1212
type ArticleDetail struct {
1313
Title string `json:"title" gorm:"primaryKey"`
1414
CreateAt *time.Time `json:"createAt" gorm:"autoCreateTime;"`
1515
UpdateAt *time.Time `json:"updateAt" gorm:"autoUpdateTime;"`
16-
Author string `json:"author" gorm:"type:VARCHAR(100)"`
16+
Author string `json:"author" gorm:"type:varchar(255)"`
1717
Content string `json:"content" gorm:"type:TEXT;index:ft_content,fulltext"`
1818
}

0 commit comments

Comments
 (0)