#10 customize base url for view and api via env variables
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func EnableCors(next http.Handler) http.Handler {
|
||||
var frontent_url = os.Getenv("FRONTEND_URL")
|
||||
if frontent_url == "" {
|
||||
log.Fatal("FRONTEND_URL is not set")
|
||||
}
|
||||
log.Println("FRONTEND_URL is", frontent_url)
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "http://localhost:5173")
|
||||
w.Header().Set("Access-Control-Allow-Origin", frontent_url)
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, DELETE")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Authorization")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user