Skip to content

Commit

Permalink
Merge pull request #227 from xuewenG/fix/swagger-page
Browse files Browse the repository at this point in the history
修复 swagger 页面无法打开
  • Loading branch information
xuewenG authored Dec 10, 2024
2 parents 18e95be + c701acd commit b2b3c8f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
6 changes: 4 additions & 2 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ func main() {
setupRouter(injector)

migrateTo3(tx, myLogger)

e.HideBanner = true
myLogger.Info().Msgf("服务端启动成功,监听:%d端口...", cfg.Port)
err = e.Start(fmt.Sprintf(":%d", cfg.Port))
if err != nil {
if err == nil {
myLogger.Info().Msgf("服务端启动成功,监听:%d端口...", cfg.Port)
} else {
myLogger.Fatal().Msgf("服务启动失败,错误原因:%s", err)
}
}
16 changes: 12 additions & 4 deletions backend/main_prod.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"embed"
"fmt"
"net/http"
"strings"

"github.com/ilyakaznacheev/cleanenv"
_ "github.com/joho/godotenv/autoload"
Expand Down Expand Up @@ -81,15 +82,22 @@ func main() {
HTML5: true,
Root: "public", // because files are located in `web` directory in `webAssets` fs
Filesystem: http.FS(staticFiles),
}))
Skipper: func(c echo.Context) bool {
if strings.HasPrefix(c.Request().URL.Path, "/swagger/") {
return true
}

e.FileFS("/*", "public/index.html", staticFiles)
return false
},
}))

migrateTo3(tx, myLogger)

e.HideBanner = true
myLogger.Info().Msgf("服务端启动成功,监听:%d端口...", cfg.Port)
err = e.Start(fmt.Sprintf(":%d", cfg.Port))
if err != nil {
if err == nil {
myLogger.Info().Msgf("服务端启动成功,监听:%d端口...", cfg.Port)
} else {
myLogger.Fatal().Msgf("服务启动失败,错误原因:%s", err)
}
}
6 changes: 5 additions & 1 deletion front/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export default defineNuxtConfig({
"/upload": {
target: "http://localhost:37892",
changeOrigin: true,
}
},
"/swagger": {
target: "http://localhost:37892",
changeOrigin: true,
},
},
},
build: {
Expand Down

0 comments on commit b2b3c8f

Please sign in to comment.