1
Fork 0

Completely remove PHOTOVIEW_PUBLIC_ENDPOINT

This commit is contained in:
viktorstrate 2021-03-01 22:10:20 +01:00
parent 2c98827db5
commit 430869b319
No known key found for this signature in database
GPG Key ID: 3F855605109C1E8A
5 changed files with 17 additions and 29 deletions

View File

@ -22,8 +22,6 @@ PHOTOVIEW_UI_ENDPOINT=http://localhost:1234/
# Set to 1 for the server to also serve the built static ui files
PHOTOVIEW_SERVE_UI=0
# When PHOTOVIEW_SERVE_UI is 1, PHOTOVIEW_PUBLIC_ENDPOINT is used instead of PHOTOVIEW_API_ENDPOINT and PHOTOVIEW_UI_ENDPOINT
#PHOTOVIEW_PUBLIC_ENDPOINT=http://localhost:4001/
# Enter a valid mapbox token, to enable maps feature
# A token can be created for free at https://mapbox.com

View File

@ -117,6 +117,8 @@ func main() {
if uiEndpoint := utils.UiEndpointUrl(); uiEndpoint != nil {
log.Printf("Photoview UI public endpoint ready at %s\n", uiEndpoint.String())
} else {
log.Println("Photoview UI public endpoint ready at /")
}
if !shouldServeUI {

View File

@ -45,43 +45,37 @@ func ApiListenUrl() *url.URL {
}
func ApiEndpointUrl() *url.URL {
apiEndpointStr := EnvAPIEndpoint.GetValue()
var apiEndpointStr string
shouldServeUI := ShouldServeUI()
if shouldServeUI {
apiEndpointStr = EnvPublicEndpoint.GetValue()
if apiEndpointStr == "" {
apiEndpointStr = "/"
}
apiEndpointStr = "/"
} else {
apiEndpointStr = EnvAPIEndpoint.GetValue()
}
apiEndpointUrl, err := url.Parse(apiEndpointStr)
apiEndpointURL, err := url.Parse(apiEndpointStr)
if err != nil {
log.Fatalf("ERROR: Environment variable %s is not a proper url (%s)", EnvAPIEndpoint.GetName(), EnvAPIEndpoint.GetValue())
}
if shouldServeUI {
apiEndpointUrl.Path = path.Join(apiEndpointUrl.Path, "/api")
apiEndpointURL.Path = path.Join(apiEndpointURL.Path, "/api")
}
return apiEndpointUrl
return apiEndpointURL
}
func UiEndpointUrl() *url.URL {
uiEndpointStr := EnvUIEndpoint.GetValue()
shouldServeUI := ShouldServeUI()
if shouldServeUI {
uiEndpointStr = EnvPublicEndpoint.GetValue()
if uiEndpointStr == "" {
return nil
}
return nil
}
uiEndpointUrl, err := url.Parse(uiEndpointStr)
uiEndpointURL, err := url.Parse(EnvUIEndpoint.GetValue())
if err != nil {
log.Fatalf("ERROR: Environment variable %s is not a proper url (%s)", EnvUIEndpoint.GetName(), EnvUIEndpoint.GetValue())
}
return uiEndpointUrl
return uiEndpointURL
}

View File

@ -15,11 +15,10 @@ const (
// Network related
const (
EnvListenIP EnvironmentVariable = "PHOTOVIEW_LISTEN_IP"
EnvListenPort EnvironmentVariable = "PHOTOVIEW_LISTEN_PORT"
EnvAPIEndpoint EnvironmentVariable = "PHOTOVIEW_API_ENDPOINT"
EnvUIEndpoint EnvironmentVariable = "PHOTOVIEW_UI_ENDPOINT"
EnvPublicEndpoint EnvironmentVariable = "PHOTOVIEW_PUBLIC_ENDPOINT"
EnvListenIP EnvironmentVariable = "PHOTOVIEW_LISTEN_IP"
EnvListenPort EnvironmentVariable = "PHOTOVIEW_LISTEN_PORT"
EnvAPIEndpoint EnvironmentVariable = "PHOTOVIEW_API_ENDPOINT"
EnvUIEndpoint EnvironmentVariable = "PHOTOVIEW_UI_ENDPOINT"
)
// Database related

View File

@ -27,11 +27,6 @@ services:
- PHOTOVIEW_LISTEN_PORT=80
- PHOTOVIEW_MEDIA_CACHE=/app/cache
# Change This: The publicly exposed url
# For example if the server is available from the domain example.com,
# change this value to http://example.com/
- PHOTOVIEW_PUBLIC_ENDPOINT=http://localhost:8000/
# Optional: To enable map related features, you need to create a mapbox token.
# A token can be generated for free here https://account.mapbox.com/access-tokens/
# It's a good idea to limit the scope of the token to your own domain, to prevent others from using it.
@ -40,7 +35,7 @@ services:
volumes:
- api_cache:/app/cache
# Change this to the directory where your photos are located on your server.
# Change This: to the directory where your photos are located on your server.
# If the photos are located at `/home/user/photos`, then change this value
# to the following: `/home/user/photos:/photos:ro`.
# You can mount multiple paths, if your photos are spread across multiple directories.