Make api URL dynamic in web app

This commit is contained in:
Anders Roos 2022-11-13 21:13:58 +01:00
parent ad12b483ff
commit 57b4862a5b
4 changed files with 76 additions and 26 deletions

View file

@ -25,8 +25,7 @@ func New(token string) *API {
func (api *API) EnableCors(fn http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Access-Control-Allow-Origin", "http://localhost:8001") // todo: configurable port
w.Header().Add("Access-Control-Allow-Credentials", "true")
w.Header().Add("Access-Control-Allow-Origin", "*")
w.Header().Add("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
w.Header().Add("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")