Skip to content

Commit

Permalink
[Panel] Fix CORS + Enalbe TLS using self-signed certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
0x9n0p committed Dec 6, 2023
1 parent 2f03b39 commit 200b114
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ var HTTPServer = func() *echo.Echo {
}()

func init() {
cors := middleware.CORSConfig{
Skipper: middleware.DefaultSkipper,
AllowOrigins: []string{"*"},
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
AllowCredentials: true,
}

root := echo.New()
root.Use(middleware.Recover())
root.Use(middleware.CORS())
root.Use(middleware.CORSWithConfig(cors))
RegisterHTTPHost("", root)
RegisterHTTPHost("www", root)

panel := echo.New()
panel.Use(middleware.Recover())
panel.Use(middleware.CORS())
panel.Use(middleware.CORSWithConfig(cors))
RegisterHTTPHost("panel", panel)

if Env.Debug {
Expand Down Expand Up @@ -74,7 +81,7 @@ func init() {
})

go func() {
if err := HTTPServer.Start(Env.HTTPServerAddress); err != nil {
if err := HTTPServer.StartTLS(Env.HTTPServerAddress, "/etc/ssl/certs/plutoengine.crt", "/etc/ssl/private/plutoengine.key"); err != nil {
Log.Fatal("Running HTTP admin server", zap.Error(err))
}
}()
Expand Down

0 comments on commit 200b114

Please sign in to comment.