Skip to content

Commit

Permalink
fix: add cors config
Browse files Browse the repository at this point in the history
  • Loading branch information
saiaunghlyanhtet committed Sep 1, 2024
1 parent 3846bee commit 09e1b39
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/handlers/api_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import (
)

func apiResponse(status int, body interface{}) (*events.APIGatewayProxyResponse, error) {
resp := events.APIGatewayProxyResponse{Headers: map[string]string{"Content-Type": "application/json"}}
resp.StatusCode = status
resp := events.APIGatewayProxyResponse{
StatusCode: status,
Headers: map[string]string{
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Content-Type": "application/json",
},
}

stringBody, _ := json.Marshal(body)
resp.Body = string(stringBody)
Expand Down

0 comments on commit 09e1b39

Please sign in to comment.