Skip to content

Commit

Permalink
Merge pull request #279 from Jinvic/dev
Browse files Browse the repository at this point in the history
修改后端获取前端域名的方式
  • Loading branch information
xuewenG authored Feb 15, 2025
2 parents 4bda6c8 + d001c0e commit ec6f6a5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
5 changes: 1 addition & 4 deletions backend/handler/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,7 @@ func (c CommentHandler) AddComment(ctx echo.Context) error {

if err = c.base.db.Save(&comment).Error; err == nil {
go func() {
frontendHost := ctx.QueryParam("frontend_host")
if frontendHost == "" {
frontendHost = ctx.Request().Host // 如果未传递,则使用后端默认的 Host
}
frontendHost := ctx.Request().Host
if err = c.commentEmailNotification(comment, frontendHost); err != nil {
c.base.log.Error().Msgf("邮件通知失败,原因:%s", err)
}
Expand Down
5 changes: 1 addition & 4 deletions backend/handler/rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ func NewRssHandler(injector do.Injector) *RssHandler {
}

func (r RssHandler) GetRss(c echo.Context) error {
frontendHost := c.QueryParam("frontend_host")
if frontendHost == "" {
frontendHost = c.Request().Host // 如果未传递,则使用后端默认的 Host
}
frontendHost := c.Request().Host
rss, err := r.generateRss(frontendHost)
if err != nil {
return FailRespWithMsg(c, Fail, "RSS生成失败")
Expand Down
2 changes: 1 addition & 1 deletion front/components/CommentBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const doComment = async (token?: string) => {
toast.error("评论字数超过限制长度:" + sysConfig.value.maxCommentLength)
return
}
await useMyFetch(`/comment/add?frontend_host=${encodeURIComponent(window.location.origin)}`, {...state, token:token})
await useMyFetch(`/comment/add`, {...state, token:token})
toast.success("评论成功!")
currentCommentBox.value = ''
state.username = ''
Expand Down
2 changes: 1 addition & 1 deletion front/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ useHead({
rel: 'alternate',
type: 'application/rss+xml',
title: '我的 RSS 订阅',
href: sysConfigVO.rss || `/rss?frontend_host=${encodeURIComponent(window.location.origin)}`,
href: sysConfigVO.rss || `/rss`,
},
],
style: [
Expand Down
8 changes: 4 additions & 4 deletions front/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export default defineNuxtConfig({
proxy: {
"/api": {
target: "http://localhost:37892",
changeOrigin: true,
// changeOrigin: true,
},
"/upload": {
target: "http://localhost:37892",
changeOrigin: true,
// changeOrigin: true,
},
"/rss": {
target: "http://localhost:37892",
changeOrigin: true,
// changeOrigin: true,
},
"/swagger": {
target: "http://localhost:37892",
changeOrigin: true,
// changeOrigin: true,
},
},
},
Expand Down

0 comments on commit ec6f6a5

Please sign in to comment.