mirror of
https://github.com/trafficlunar/api.git
synced 2026-06-27 22:24:08 +00:00
fix: add development mode environment variable
This commit is contained in:
parent
43628a1a66
commit
a864e689be
2 changed files with 13 additions and 1 deletions
|
|
@ -14,6 +14,16 @@ import (
|
|||
"backend/internal/handler"
|
||||
)
|
||||
|
||||
func getAllowedOrigins() []string {
|
||||
allowedOrigins := []string{"https://axolotlmaid.com"}
|
||||
|
||||
if os.Getenv("DEVELOPMENT_MODE") == "true" {
|
||||
allowedOrigins = append(allowedOrigins, "http://localhost:4321")
|
||||
}
|
||||
|
||||
return allowedOrigins
|
||||
}
|
||||
|
||||
func NewRouter() {
|
||||
r := chi.NewRouter()
|
||||
|
||||
|
|
@ -26,7 +36,7 @@ func NewRouter() {
|
|||
r.Use(middleware.Timeout(60 * time.Second))
|
||||
r.Use(httprate.LimitByRealIP(32, time.Minute))
|
||||
r.Use(cors.Handler(cors.Options{
|
||||
AllowedOrigins: []string{"https://axolotlmaid.com"},
|
||||
AllowedOrigins: getAllowedOrigins(),
|
||||
AllowedMethods: []string{"GET", "PATCH"},
|
||||
AllowedHeaders: []string{"Content-Type"},
|
||||
MaxAge: 300,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue