Allow overriding Super Dev Mode server URL via prompt#10344
Conversation
If the SDM server is unreachable, a prompt now allows users to specify a new server URL. This URL is persisted in sessionStorage so it can be used during the subsequent page reload.
niloc132
left a comment
There was a problem hiding this comment.
I like the idea, and at a quick glance the implementation seems okay - but doesn't the bookmarklet setup solve this too? That is, if you first start mysdm:9876 and visit that URL, the bookmarklets let you enable SDM in session storage?
My current usage is atypical, so I may well be misremembering.
| try { | ||
| serverUrl = $wnd.sessionStorage.getItem(serverUrlKey) || defaultServerUrl; | ||
| } catch (e) { | ||
| // sessionStorage may be unavailable; fall back to the default url. |
There was a problem hiding this comment.
What's the risk/likelihood that session storage is unavailable? dev_mode_on.js relies on it and won't function without it, so I think maybe we can assume it is there?
| try { | ||
| $wnd.sessionStorage.setItem(serverUrlKey, newServerUrl); | ||
| } catch (e) { | ||
| // Without storage the reload falls back to the default url. |
There was a problem hiding this comment.
(assuming still relevant) Should probably notify that the prompt had no effect?
Maybe test for storage usage before attempting to use prompt to begin with?
I haven't used the bookmarklets in so long, I thought they were abandoned with the old dev mode and replaced by SDM. I'll remove the check for sessionstorage availability, I was not aware of it being used for other GWT functionality. 👍 |
Remove try-catch blocks around sessionStorage interactions when retrieving or persisting the Super Dev Mode server URL since we know sessionStorage is already available and used in dev_mode_on.js.
If the SDM server is unreachable, a prompt now allows users to specify a new server URL. This URL is persisted in sessionStorage so it can be used during the subsequent page reload.
This makes it possible to use https://github.com/localtunnel/localtunnel or other similar services (that tunnel specific ports) to share the local dev environment with other people without having to build and deploy the app on some other server.