Skip to content

Commit

Permalink
feat: added fetching cors options from envs
Browse files Browse the repository at this point in the history
  • Loading branch information
TakSeBiegam committed Dec 13, 2023
1 parent 07eb9af commit 984a8e7
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions cmd/local/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ package localcmd

import (
"flag"
"fmt"
"net/http"

crs "github.com/graphql-editor/stucco/pkg/cors"

Check failure on line 24 in cmd/local/start.go

View workflow job for this annotation

GitHub Actions / build_cli (1.18.x, ubuntu-latest, amd64)

no required module provides package github.com/graphql-editor/stucco/pkg/cors; to add it:

Check failure on line 24 in cmd/local/start.go

View workflow job for this annotation

GitHub Actions / build_cli (1.18.x, ubuntu-latest, 386)

no required module provides package github.com/graphql-editor/stucco/pkg/cors; to add it:

Check failure on line 24 in cmd/local/start.go

View workflow job for this annotation

GitHub Actions / build_cli (1.18.x, ubuntu-latest, arm64)

no required module provides package github.com/graphql-editor/stucco/pkg/cors; to add it:

Check failure on line 24 in cmd/local/start.go

View workflow job for this annotation

GitHub Actions / build_cli (1.18.x, ubuntu-latest, amd64)

no required module provides package github.com/graphql-editor/stucco/pkg/cors; to add it:

Check failure on line 24 in cmd/local/start.go

View workflow job for this annotation

GitHub Actions / build_cli (1.18.x, ubuntu-latest, 386)

no required module provides package github.com/graphql-editor/stucco/pkg/cors; to add it:

Check failure on line 24 in cmd/local/start.go

View workflow job for this annotation

GitHub Actions / build_cli (1.18.x, ubuntu-latest, arm64)

no required module provides package github.com/graphql-editor/stucco/pkg/cors; to add it:
"github.com/graphql-editor/stucco/pkg/handlers"
"github.com/graphql-editor/stucco/pkg/server"
"github.com/graphql-editor/stucco/pkg/utils"
Expand Down Expand Up @@ -63,21 +65,16 @@ func NewStartCommand() *cobra.Command {
if err != nil {
return err
}
corsOptions := crs.NewCors()
fmt.Println(corsOptions.AllowedOrigins)
middleware := func(next http.Handler) http.Handler {
return handlers.RecoveryHandler(
httplog.WithLogging(
cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{
http.MethodHead,
http.MethodGet,
http.MethodPost,
http.MethodPut,
http.MethodPatch,
http.MethodDelete,
},
AllowedHeaders: []string{"*"},
AllowCredentials: true,
AllowedOrigins: corsOptions.AllowedOrigins,
AllowedMethods: corsOptions.AllowedMethods,
AllowedHeaders: corsOptions.AllowedHeaders,
AllowCredentials: corsOptions.AllowedCredentials,
}).Handler(next),
httplog.DefaultStacktracePred,
),
Expand Down

0 comments on commit 984a8e7

Please sign in to comment.