From 74a27297f4505c32f18696518c1f08d3d357a65f Mon Sep 17 00:00:00 2001 From: Ales Verbic Date: Thu, 2 Nov 2023 09:38:22 -0400 Subject: [PATCH] feat: get host from a request Signed-off-by: Ales Verbic --- output/push/api_routes.go | 4 ++-- output/push/qr_generator.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/output/push/api_routes.go b/output/push/api_routes.go index b882580..ad716ca 100644 --- a/output/push/api_routes.go +++ b/output/push/api_routes.go @@ -29,9 +29,9 @@ func (p *PushOutput) RegisterRoutes() { apiInstance := api.GetInstance() var apiEndpoint string if apiInstance.ApiGroup != nil { - apiEndpoint = apiInstance.Host + apiInstance.ApiGroup.BasePath() + "/fcm" + apiEndpoint = apiInstance.ApiGroup.BasePath() + "/fcm" } else { - apiEndpoint = apiInstance.Host + "/fcm" + apiEndpoint = "/fcm" } apiInstance.AddRoute("POST", "/fcm", storeFCMToken) diff --git a/output/push/qr_generator.go b/output/push/qr_generator.go index 46b7797..4bf16b8 100644 --- a/output/push/qr_generator.go +++ b/output/push/qr_generator.go @@ -15,6 +15,7 @@ type QRValue struct { func generateQRPage(apiEndpoint string) gin.HandlerFunc { return func(c *gin.Context) { + apiEndpoint = c.Request.Host + apiEndpoint qrValue, err := json.Marshal(QRValue{ ApiEndpoint: apiEndpoint, })