Skip to content

Commit

Permalink
[fix] swagger切り離しのためcors修正
Browse files Browse the repository at this point in the history
  • Loading branch information
hikahana committed Dec 23, 2024
1 parent bdbf70e commit af2d0b9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions api/drivers/server/server.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package server

import (
_ "github.com/NUTFes/FinanSu/api/docs"
"net/http"
"os"

"github.com/NUTFes/FinanSu/api/router"
"github.com/labstack/echo/v4"

Check failure on line 8 in api/drivers/server/server.go

View workflow job for this annotation

GitHub Actions / golangci-lint

"github.com/labstack/echo/v4" imported but not used (typecheck)
"github.com/labstack/echo/v4/middleware"
echoSwagger "github.com/swaggo/echo-swagger"
"net/http"
"os"
)

func RunServer(router router.Router) {
Expand All @@ -28,16 +27,13 @@ func RunServer(router router.Router) {

// CORS対策
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"http://localhost:3000", "127.0.0.1:3000", "http://localhost:3001", "127.0.0.1:3001", "https://finansu.nutfes.net"}, // ドメイン
AllowOrigins: []string{"http://localhost:3000", "127.0.0.1:3000", "http://localhost:3001", "127.0.0.1:3001", "http://localhost:8000", "127.0.0.1:8000", "https://finansu.nutfes.net"}, // ドメイン
AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete},
}))

// ルーティング
router.ProvideRouter(e)

// swagger
e.GET("/swagger/*", echoSwagger.WrapHandler)

// サーバー起動
e.Start(":1323")
}

0 comments on commit af2d0b9

Please sign in to comment.