Skip to content

Commit 36d9861

Browse files
committed
Fix getting host
1 parent 4e48320 commit 36d9861

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ FROM alpine:latest
2424
WORKDIR /root/
2525
RUN mkdir app dashboard
2626
COPY --from=node-builder /authorizer/app/build app/build
27+
COPY --from=node-builder /authorizer/app/favicon_io app/favicon_io
2728
COPY --from=node-builder /authorizer/dashboard/build dashboard/build
29+
COPY --from=node-builder /authorizer/dashboard/favicon_io dashboard/favicon_io
2830
COPY --from=go-builder /authorizer/build build
2931
COPY templates templates
3032
EXPOSE 8080

app/src/Root.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ const Dashboard = lazy(() => import('./pages/dashboard'));
99
export default function Root() {
1010
const { token, loading, config } = useAuthorizer();
1111

12+
console.log(config);
1213
useEffect(() => {
1314
if (token) {
1415
const url = new URL(config.redirectURL || '/app');
16+
console.log('=> url', url);
1517
if (url.origin !== window.location.origin) {
1618
window.location.href = config.redirectURL || '/app';
1719
}

server/handlers/app.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ func AppHandler() gin.HandlerFunc {
3333
var stateObj State
3434

3535
if state == "" {
36-
3736
stateObj.AuthorizerURL = hostname
38-
stateObj.RedirectURL = stateObj.AuthorizerURL + "/app"
39-
37+
stateObj.RedirectURL = hostname + "/app"
4038
} else {
4139
decodedState, err := utils.DecryptB64(state)
4240
if err != nil {

server/utils/urls.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import (
1010

1111
// GetHost returns hostname from request context
1212
func GetHost(c *gin.Context) string {
13-
scheme := "http"
14-
if c.Request.TLS != nil {
15-
scheme = "https"
13+
scheme := c.Request.Header.Get("X-Forwarded-Proto")
14+
if scheme != "https" {
15+
scheme = "http"
1616
}
17-
log.Println("=> url:", scheme+"://"+c.Request.Host)
18-
return scheme + "://" + c.Request.Host
17+
host := c.Request.Host
18+
log.Println("=> host:", scheme+"://"+host)
19+
return scheme + "://" + host
1920
}
2021

2122
// GetHostName function returns hostname and port

0 commit comments

Comments
 (0)