Fix up accessing ui in dev mode via env variables
This commit is contained in:
parent
38bd348737
commit
4208190c9a
3 changed files with 8 additions and 5 deletions
2
main.go
2
main.go
|
@ -54,7 +54,7 @@ func main() {
|
|||
func Routes() *chi.Mux {
|
||||
router := chi.NewRouter()
|
||||
cors := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"https://sudoscientist.com", "https://www.sudoscientist.com"},
|
||||
AllowedOrigins: []string{os.Getenv("UI_PROTO") + os.Getenv("UI_ADDR") + os.Getenv("UI_PORT"), os.Getenv("UI_PROTO") + "www." + os.Getenv("UI_ADDR") + os.Getenv("UI_PORT")},
|
||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
||||
AllowCredentials: true,
|
||||
|
|
|
@ -260,9 +260,9 @@ func refresh(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func setCookies(w http.ResponseWriter, jwt string, expiration time.Time) {
|
||||
splitToken := strings.Split(jwt, ".")
|
||||
dataCookie := http.Cookie{Name: "DataCookie", Value: strings.Join(splitToken[:2], "."), Expires: expiration, HttpOnly: false, Path: "/", Domain: ".sudoscientist.com", MaxAge: 360, Secure: true}
|
||||
dataCookie := http.Cookie{Name: "DataCookie", Value: strings.Join(splitToken[:2], "."), Expires: expiration, HttpOnly: false, Path: "/", Domain: os.Getenv("UI_ADDR"), MaxAge: 360}
|
||||
http.SetCookie(w, &dataCookie)
|
||||
signatureCookie := http.Cookie{Name: "SignatureCookie", Value: splitToken[2], Expires: expiration, HttpOnly: true, Path: "/", Domain: ".sudoscientist.com", MaxAge: 360, Secure: true}
|
||||
signatureCookie := http.Cookie{Name: "SignatureCookie", Value: splitToken[2], Expires: expiration, HttpOnly: true, Path: "/", Domain: os.Getenv("UI_ADDR"), MaxAge: 360}
|
||||
http.SetCookie(w, &signatureCookie)
|
||||
return
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ func setCookies(w http.ResponseWriter, jwt string, expiration time.Time) {
|
|||
func sendEmailToken(w http.ResponseWriter, token string, name string, email string) (returnMessage ReturnMessage, ok bool) {
|
||||
header := "Thanks for joining sudoscientist, " + name + "!"
|
||||
body := "\n\nPlease click the following link to verify your email: "
|
||||
link := os.Getenv("WEB_ADDR") + "/v1/api/auth/verify/" + token
|
||||
link := os.Getenv("API_ADDR") + "/v1/api/auth/verify/" + token
|
||||
email_array := [1]string{email}
|
||||
composed_email := ComposedEmail{
|
||||
To: email_array,
|
||||
|
|
|
@ -3,4 +3,7 @@ export EMAIL_SECRET="CHANGEMEALSOPLS"
|
|||
export JWT_SECRET="CHANGEMEALSO"
|
||||
export POSTAL_API="https://POSTAL_URL"
|
||||
export POSTAL_SRC_EMAIL="postal-source@domain.com"
|
||||
export WEB_ADDR="https://apidomain.tld"
|
||||
export API_ADDR="https://apidomain.tld"
|
||||
export UI_ADDR="sudosci.ui"
|
||||
export UI_PORT=":3000"
|
||||
export UI_PROTO="http://"
|
||||
|
|
Reference in a new issue