diff --git a/.docker/vhost.conf b/.docker/vhost.conf index 03abcea3..2ab6ccf0 100644 --- a/.docker/vhost.conf +++ b/.docker/vhost.conf @@ -7,8 +7,10 @@ server { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host; proxy_pass http://node:3000; - add_header Cache-Control "public, max-age=604800"; - expires 7d; + + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; + add_header Pragma "no-cache"; + add_header Expires "0"; } location /client/ws { diff --git a/CHANGELOG.md b/CHANGELOG.md index 156bf852..0f12c4f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. ## Unreleased +## [2.1.1] - 2024-10-23 + +- [#138](https://github.com/os2display/display-client/pull/138) + - Avoided setting ER105 in url when no token exists in local storage. +- [#137](https://github.com/os2display/display-client/pull/137) + - Add `no-cacheĀ“ directive to nginx setup. + ## [2.1.0] - 2024-10-23 - [#135](https://github.com/os2display/display-client/pull/135) diff --git a/infrastructure/itkdev/etc/confd/templates/default.conf.tmpl b/infrastructure/itkdev/etc/confd/templates/default.conf.tmpl index 787669db..e35f3a92 100644 --- a/infrastructure/itkdev/etc/confd/templates/default.conf.tmpl +++ b/infrastructure/itkdev/etc/confd/templates/default.conf.tmpl @@ -3,12 +3,15 @@ server { server_name localhost; root /var/www/html; + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; + add_header Pragma "no-cache"; + add_header Expires "0"; + location {{ getenv "APP_SCREEN_CLIENT_PATH" "/" }} { rewrite ^{{ getenv "APP_SCREEN_CLIENT_PATH" "/" }}(.*) /$1 break; index index.html; autoindex off; - add_header Cache-Control "public, max-age=604800"; - expires 7d; + try_files $uri $uri/ =404; } diff --git a/infrastructure/os2display/etc/confd/templates/default.conf.tmpl b/infrastructure/os2display/etc/confd/templates/default.conf.tmpl index 787669db..e35f3a92 100644 --- a/infrastructure/os2display/etc/confd/templates/default.conf.tmpl +++ b/infrastructure/os2display/etc/confd/templates/default.conf.tmpl @@ -3,12 +3,15 @@ server { server_name localhost; root /var/www/html; + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; + add_header Pragma "no-cache"; + add_header Expires "0"; + location {{ getenv "APP_SCREEN_CLIENT_PATH" "/" }} { rewrite ^{{ getenv "APP_SCREEN_CLIENT_PATH" "/" }}(.*) /$1 break; index index.html; autoindex off; - add_header Cache-Control "public, max-age=604800"; - expires 7d; + try_files $uri $uri/ =404; } diff --git a/public/online-check/index.html b/public/online-check/index.html index 61f78166..4fccdd76 100644 --- a/public/online-check/index.html +++ b/public/online-check/index.html @@ -18,7 +18,7 @@ } body { - background-color: #333333; + background-color: #000000; margin-top: 10%; text-align: center; font-family: Arial,Helvetica,sans-serif; @@ -71,7 +71,7 @@ const checkOnlineStatus = async () => { try { - const online = await fetch("1pixel.png?no_cache=" + Date.now()); + const online = await fetch("1pixel.png?ts=" + Date.now()); return online.status >= 200 && online.status < 300; // either true or false } catch (err) { return false; // definitely offline @@ -87,7 +87,7 @@ helpDisplay.textContent = "Redirecting to client..."; setTimeout(async () => { - window.location.assign("../"); + window.location.assign("../?ts="+ Date.now()); }, 3000 ) } diff --git a/src/app.scss b/src/app.scss index 520da5e0..2f68c5a8 100644 --- a/src/app.scss +++ b/src/app.scss @@ -27,6 +27,8 @@ body { color: white; padding: 0; margin: 0; + font-family: monospace; + font-size: 2em; } .bind-key-container { diff --git a/src/service/token-service.js b/src/service/token-service.js index a411fed7..70bd57e5 100644 --- a/src/service/token-service.js +++ b/src/service/token-service.js @@ -53,6 +53,17 @@ class TokenService { getExpireState = () => { const expire = appStorage.getTokenExpire(); const issueAt = appStorage.getTokenIssueAt(); + const token = appStorage.getToken(); + + if (expire === null) { + return constants.NO_EXPIRE; + } + if (issueAt === null) { + return constants.NO_ISSUED_AT; + } + if (token === null) { + return constants.NO_TOKEN; + } const timeDiff = expire - issueAt; const nowSeconds = Math.floor(new Date().getTime() / 1000); @@ -121,11 +132,11 @@ class TokenService { checkToken = () => { const expiredState = this.getExpireState(); - if (expiredState === constants.TOKEN_EXPIRED) { + if ([constants.NO_EXPIRE, constants.NO_ISSUED_AT, constants.NO_TOKEN].includes(expiredState)) { + // Ignore. No token saved in storage. + } else if (expiredState === constants.TOKEN_EXPIRED) { statusService.setError(constants.ERROR_TOKEN_EXPIRED); - } else if ( - expiredState === constants.TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED - ) { + } else if (expiredState === constants.TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED) { statusService.setError( constants.ERROR_TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED ); diff --git a/src/util/constants.js b/src/util/constants.js index a4175a85..9742ef22 100644 --- a/src/util/constants.js +++ b/src/util/constants.js @@ -14,6 +14,9 @@ const constants = { ERROR_RELEASE_FILE_NOT_LOADED: 'ER104', // Release file could not be loaded. ERROR_TOKEN_EXPIRED: 'ER105', // Token is expired. ERROR_TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED: 'ER106', // Token is valid but should have been refreshed. + NO_TOKEN: 'NO_TOKEN', + NO_EXPIRE: 'NO_EXPIRE', + NO_ISSUED_AT: 'NO_ISSUED_AT', }; export default constants;