diff --git a/api/graphql/models/media.go b/api/graphql/models/media.go
index cd8e093..3f03cd9 100644
--- a/api/graphql/models/media.go
+++ b/api/graphql/models/media.go
@@ -74,14 +74,14 @@ type MediaURL struct {
 
 func (p *MediaURL) URL() string {
 
-	imageUrl := utils.ApiEndpointUrl()
+	imageURL := utils.ApiEndpointUrl()
 	if p.Purpose != VideoWeb {
-		imageUrl.Path = path.Join(imageUrl.Path, "photo", p.MediaName)
+		imageURL.Path = path.Join(imageURL.Path, "photo", p.MediaName)
 	} else {
-		imageUrl.Path = path.Join(imageUrl.Path, "video", p.MediaName)
+		imageURL.Path = path.Join(imageURL.Path, "video", p.MediaName)
 	}
 
-	return imageUrl.String()
+	return imageURL.String()
 }
 
 func (p *MediaURL) CachedPath() (string, error) {
diff --git a/api/graphql/resolvers/mediaGeoJson.go b/api/graphql/resolvers/mediaGeoJson.go
index 3f65743..4dd6493 100644
--- a/api/graphql/resolvers/mediaGeoJson.go
+++ b/api/graphql/resolvers/mediaGeoJson.go
@@ -2,10 +2,11 @@ package resolvers
 
 import (
 	"context"
-	"github.com/photoview/photoview/api/graphql/auth"
-	"github.com/photoview/photoview/api/utils"
 	"os"
 	"path"
+
+	"github.com/photoview/photoview/api/graphql/auth"
+	"github.com/photoview/photoview/api/utils"
 )
 
 type geoMedia struct {
diff --git a/api/server.go b/api/server.go
index 2b321d0..4b6dec0 100644
--- a/api/server.go
+++ b/api/server.go
@@ -73,12 +73,12 @@ func main() {
 		Directives: graphqlDirective,
 	}
 
-	apiListenUrl := utils.ApiListenUrl()
+	apiListenURL := utils.ApiListenUrl()
 
-	endpointRouter := rootRouter.PathPrefix(apiListenUrl.Path).Subrouter()
+	endpointRouter := rootRouter.PathPrefix(apiListenURL.Path).Subrouter()
 
 	if devMode {
-		endpointRouter.Handle("/", handler.Playground("GraphQL playground", path.Join(apiListenUrl.Path, "/graphql")))
+		endpointRouter.Handle("/", handler.Playground("GraphQL playground", path.Join(apiListenURL.Path, "/graphql")))
 	} else {
 		endpointRouter.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
 			w.Write([]byte("photoview api endpoint"))
@@ -108,15 +108,16 @@ func main() {
 	}
 
 	if devMode {
-		log.Printf("🚀 Graphql playground ready at %s\n", apiListenUrl.String())
+		log.Printf("🚀 Graphql playground ready at %s\n", apiListenURL.String())
 	} else {
-		log.Printf("Photoview API endpoint listening at %s\n", apiListenUrl.String())
+		log.Printf("Photoview API endpoint listening at %s\n", apiListenURL.String())
 
-		uiEndpoint := utils.UiEndpointUrl()
 		apiEndpoint := utils.ApiEndpointUrl()
-
 		log.Printf("Photoview API public endpoint ready at %s\n", apiEndpoint.String())
-		log.Printf("Photoview UI public endpoint ready at %s\n", uiEndpoint.String())
+
+		if uiEndpoint := utils.UiEndpointUrl(); uiEndpoint != nil {
+			log.Printf("Photoview UI public endpoint ready at %s\n", uiEndpoint.String())
+		}
 
 		if !shouldServeUI {
 			log.Printf("Notice: UI is not served by the the api (%s=0)", utils.EnvServeUI.GetName())
@@ -124,5 +125,5 @@ func main() {
 
 	}
 
-	log.Panic(http.ListenAndServe(":"+apiListenUrl.Port(), handlers.CompressHandler(rootRouter)))
+	log.Panic(http.ListenAndServe(":"+apiListenURL.Port(), handlers.CompressHandler(rootRouter)))
 }
diff --git a/api/server/cors_middleware.go b/api/server/cors_middleware.go
index 244265f..28e2d06 100644
--- a/api/server/cors_middleware.go
+++ b/api/server/cors_middleware.go
@@ -2,7 +2,7 @@ package server
 
 import (
 	"net/http"
-	"path"
+	"net/url"
 	"strings"
 
 	"github.com/gorilla/mux"
@@ -13,17 +13,7 @@ func CORSMiddleware(devMode bool) mux.MiddlewareFunc {
 	return func(next http.Handler) http.Handler {
 		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
 
-			methods := []string{http.MethodGet, http.MethodPost, http.MethodOptions}
-			requestHeaders := []string{"authorization", "content-type", "content-length", "TokenPassword"}
-			responseHeaders := []string{"content-length"}
-
-			w.Header().Set("Access-Control-Allow-Methods", strings.Join(methods, ", "))
-			w.Header().Set("Access-Control-Allow-Headers", strings.Join(requestHeaders, ", "))
-			w.Header().Set("Access-Control-Allow-Credentials", "true")
-			w.Header().Set("Access-Control-Expose-Headers", strings.Join(responseHeaders, ", "))
-
-			endpoint := utils.ApiEndpointUrl()
-			endpoint.Path = path.Join(endpoint.Path, "graphql")
+			var uiEndpoint *url.URL = nil
 
 			if devMode {
 				// Development environment
@@ -31,8 +21,23 @@ func CORSMiddleware(devMode bool) mux.MiddlewareFunc {
 				w.Header().Set("Vary", "Origin")
 			} else {
 				// Production environment
-				uiEndpoint := utils.UiEndpointUrl()
-				w.Header().Set("Access-Control-Allow-Origin", uiEndpoint.Scheme+"://"+uiEndpoint.Host)
+				uiEndpoint = utils.UiEndpointUrl()
+				if uiEndpoint != nil {
+					// Only allow CORS if UI endpoint is defined
+					w.Header().Set("Access-Control-Allow-Origin", uiEndpoint.Scheme+"://"+uiEndpoint.Host)
+				}
+			}
+
+			corsEnabled := devMode || uiEndpoint != nil
+			if corsEnabled {
+				methods := []string{http.MethodGet, http.MethodPost, http.MethodOptions}
+				requestHeaders := []string{"authorization", "content-type", "content-length", "TokenPassword"}
+				responseHeaders := []string{"content-length"}
+
+				w.Header().Set("Access-Control-Allow-Methods", strings.Join(methods, ", "))
+				w.Header().Set("Access-Control-Allow-Headers", strings.Join(requestHeaders, ", "))
+				w.Header().Set("Access-Control-Allow-Credentials", "true")
+				w.Header().Set("Access-Control-Expose-Headers", strings.Join(responseHeaders, ", "))
 			}
 
 			if req.Method != http.MethodOptions {
diff --git a/api/server/websocket.go b/api/server/websocket.go
index 3b11946..70cbdf8 100644
--- a/api/server/websocket.go
+++ b/api/server/websocket.go
@@ -16,6 +16,9 @@ func WebsocketUpgrader(devMode bool) websocket.Upgrader {
 				return true
 			} else {
 				uiEndpoint := utils.UiEndpointUrl()
+				if uiEndpoint == nil {
+					return true
+				}
 
 				if r.Header.Get("origin") == "" {
 					return true
diff --git a/api/utils/Endpoints.go b/api/utils/Endpoints.go
index 30ec5f7..cf542b7 100644
--- a/api/utils/Endpoints.go
+++ b/api/utils/Endpoints.go
@@ -50,6 +50,9 @@ func ApiEndpointUrl() *url.URL {
 	shouldServeUI := ShouldServeUI()
 	if shouldServeUI {
 		apiEndpointStr = EnvPublicEndpoint.GetValue()
+		if apiEndpointStr == "" {
+			apiEndpointStr = "/"
+		}
 	}
 
 	apiEndpointUrl, err := url.Parse(apiEndpointStr)
@@ -70,6 +73,9 @@ func UiEndpointUrl() *url.URL {
 	shouldServeUI := ShouldServeUI()
 	if shouldServeUI {
 		uiEndpointStr = EnvPublicEndpoint.GetValue()
+		if uiEndpointStr == "" {
+			return nil
+		}
 	}
 
 	uiEndpointUrl, err := url.Parse(uiEndpointStr)
diff --git a/ui/src/Pages/PeoplePage/PeoplePage.js b/ui/src/Pages/PeoplePage/PeoplePage.js
index 78d19ba..7f82c63 100644
--- a/ui/src/Pages/PeoplePage/PeoplePage.js
+++ b/ui/src/Pages/PeoplePage/PeoplePage.js
@@ -56,6 +56,7 @@ const RECOGNIZE_UNLABELED_FACES_MUTATION = gql`
 
 const FaceDetailsButton = styled.button`
   color: ${({ labeled }) => (labeled ? 'black' : '#aaa')};
+  width: 150px;
   margin: 12px auto 24px;
   text-align: center;
   display: block;
diff --git a/ui/src/components/photoGallery/ProtectedMedia.js b/ui/src/components/photoGallery/ProtectedMedia.js
index 68b26e6..df34b80 100644
--- a/ui/src/components/photoGallery/ProtectedMedia.js
+++ b/ui/src/components/photoGallery/ProtectedMedia.js
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
 const getProtectedUrl = url => {
   if (url == null) return null
 
-  const imgUrl = new URL(url)
+  const imgUrl = new URL(url, location.origin)
 
   const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
   if (tokenRegex) {
