diff --git a/CHANGELOG.md b/CHANGELOG.md index e320744..b81dc4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.4.1 (2021-10-31) + +### Bug fixes +- Provide a way to specify the host URL in the QR code (don't know how I missed + this!) + ## 0.4.0 (2021-09-21) ### New features diff --git a/README.md b/README.md index 6d79bdb..24f8860 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,17 @@ const ( staticDir = "./public" driver = "sqlite3" dataSource = "sqlite_db" + // This is only for generating the QR code from a URL since when it's + // running behind nginx, for example, it doesn't know what the outside + // facing hostname is unless we tell it. A real setup might look like: + // this program running on localhost:8090, but nginx accepts requests at + // https://file.com, in which case the below value would be https://file.com + publicHost = "https://goupfile.com" ) ``` +These probably should be moved to environment variables. + ### Proxying though nginx It's common to proxy requests through a server like nginx. This allows you to diff --git a/handlers.go b/handlers.go index 7a60da6..64f1df9 100644 --- a/handlers.go +++ b/handlers.go @@ -100,7 +100,7 @@ func createURL(id, action string) string { func createQR(url string) []byte { var png []byte - qr, err := qrcode.New(url, qrcode.Medium) + qr, err := qrcode.New(publicHost+url, qrcode.Medium) if err != nil { log.Println("Unable to create QR code: ", err) } diff --git a/main.go b/main.go index f34f967..45354aa 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,12 @@ const ( staticDir = "./public" driver = "sqlite3" dataSource = "sqlite_db" + // This is only for generating the QR code from a URL since when it's + // running behind nginx, for example, it doesn't know what the outside + // facing hostname is unless we tell it. A real setup might look like: + // this program running on localhost:8090, but nginx accepts requests at + // https://file.com, in which case the below value would be https://file.com + publicHost = "https://goupfile.com" ) const schema = `