File tree Expand file tree Collapse file tree 6 files changed +36
-17
lines changed Expand file tree Collapse file tree 6 files changed +36
-17
lines changed Original file line number Diff line number Diff line change 1111 "author" : " Lakhan Samani" ,
1212 "license" : " ISC" ,
1313 "dependencies" : {
14- "@authorizerdev/authorizer-react" : " latest " ,
14+ "@authorizerdev/authorizer-react" : " ^0.17.0 " ,
1515 "@types/react" : " ^17.0.15" ,
1616 "@types/react-dom" : " ^17.0.9" ,
1717 "esbuild" : " ^0.12.17" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ const queryClient = createClient({
1010 fetchOptions : ( ) => {
1111 return {
1212 credentials : 'include' ,
13+ headers : {
14+ 'x-authorizer-url' : window . location . origin ,
15+ } ,
1316 } ;
1417 } ,
1518 requestPolicy : 'network-only' ,
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ const (
1616 // EnvKeyEnvPath key for cli arg variable ENV_PATH
1717 EnvKeyEnvPath = "ENV_PATH"
1818 // EnvKeyAuthorizerURL key for env variable AUTHORIZER_URL
19- // TODO: remove support AUTHORIZER_URL env
2019 EnvKeyAuthorizerURL = "AUTHORIZER_URL"
2120 // EnvKeyPort key for env variable PORT
2221 EnvKeyPort = "PORT"
Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ func InitAllEnv() error {
113113 envData .StringEnv [constants .EnvKeyAppURL ] = os .Getenv (constants .EnvKeyAppURL )
114114 }
115115
116+ if envData .StringEnv [constants .EnvKeyAuthorizerURL ] == "" {
117+ envData .StringEnv [constants .EnvKeyAuthorizerURL ] = os .Getenv (constants .EnvKeyAuthorizerURL )
118+ }
119+
116120 if envData .StringEnv [constants .EnvKeyPort ] == "" {
117121 envData .StringEnv [constants .EnvKeyPort ] = os .Getenv (constants .EnvKeyPort )
118122 if envData .StringEnv [constants .EnvKeyPort ] == "" {
Original file line number Diff line number Diff line change @@ -10,7 +10,20 @@ import (
1010)
1111
1212// GetHost returns hostname from request context
13+ // if X-Authorizer-URL header is set it is given highest priority
14+ // if EnvKeyAuthorizerURL is set it is given second highest priority.
15+ // if above 2 are not set the requesting host name is used
1316func GetHost (c * gin.Context ) string {
17+ authorizerURL := c .Request .Header .Get ("X-Authorizer-URL" )
18+ if authorizerURL != "" {
19+ return authorizerURL
20+ }
21+
22+ authorizerURL = envstore .EnvStoreObj .GetStringStoreEnvVariable (constants .EnvKeyAuthorizerURL )
23+ if authorizerURL != "" {
24+ return authorizerURL
25+ }
26+
1427 scheme := c .Request .Header .Get ("X-Forwarded-Proto" )
1528 if scheme != "https" {
1629 scheme = "http"
You can’t perform that action at this time.
0 commit comments