Skip to content

Commit 059c65b

Browse files
committed
fix(build): release 启动时校验前端嵌入
release 构建缺少 embed 标签时立即失败,并在版本信息中输出构建类型和前端嵌入状态,避免 API 健康但首页 404。
1 parent 77a29cb commit 059c65b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

backend/cmd/server/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,13 @@ func main() {
153153
log.Fatalf("Invalid command options: %v", err)
154154
}
155155

156+
hasEmbeddedFrontend := web.HasEmbeddedFrontend()
157+
if BuildType == "release" && !hasEmbeddedFrontend {
158+
log.Fatal("Invalid release build: frontend is missing; build the frontend and rebuild the server with -tags embed")
159+
}
160+
156161
if *showVersion {
157-
log.Printf("Sub2API %s (commit: %s, built: %s)\n", Version, Commit, Date)
162+
log.Printf("Sub2API %s (commit: %s, built: %s, build type: %s, frontend embedded: %t)\n", Version, Commit, Date, BuildType, hasEmbeddedFrontend)
158163
return
159164
}
160165

0 commit comments

Comments
 (0)