Hi Guys Is there any way I can open a specific br...
# box-products
c
Hi Guys Is there any way I can open a specific browser from:
Copy code
server.json
Why? I have both Lucee & ACF powering the same local repo, using IIS, BonCode and CommandBox. If I open both versions in the same browser, I get a SESSION issue. I have resolved this issue, by opening the ACF version in Chrome and the Lucee version in Firefox. Currently, it is a hell of an effort, having to copy and paste the URL from Chrome into Firefox. I wondered, if there is a way I can alleviate this massive stress.πŸ˜‰ But, seriously, I am kind of interested to know if we have this option? πŸ™ Update: Theoretically, I could create a Windows shortcut and then do:
Copy code
"openBrowserURL":"C:\\somepathTo\\shortcut-website-open-in-firefox - shortcut",
The question is, will this property accept a system path? I will tell you soon. Watch this space? 😊
j
I'm following along your though processes as a virtual rubber duck πŸ™‚
πŸ‘ 1
b
@Charles Robertson You can set the default browser you want in general in the global config setting
preferredBrowser
but that doesn't quite give you what you want
πŸ‘ 1
You'll notice the
server open
command also has a
browser
argument
So you can override at the point you manually open like so
Copy code
server open browser=chrome
πŸ‘ 1
πŸ‘πŸ» 1
c
That’s will work, nicely. Thanks πŸ™
b
What we don't have is a
server.json
setting to override the browser used for the "automatic" browser that runwar pops up after your server starts. That just pulls your global
preferreedBrowser
setting
It would be pretty easy to add a new
server.json
setting for this-- can you put in a ticket please?
In the mean time, you can also add a server script in your
server.json
to help
Copy code
{
  "scripts": {
    "foo": "server open browser=chrome"
  }
}
which you can fire with
Copy code
server run-script foo
Or, you could add a custom tray icon to your system tray that opened a specific browser as well. You wouldn't want to use the
openbrowser
option as that would still use the default browser. You'd use
runAsync
and then fire whatever command yo wanted. https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/custom-tray-menus#runasync-example
c
Excellent. Currently, I am hitting a short cut. Amazingly, this works:
Copy code
"openBrowserURL":"C:\\somepathTo\\shortcut-website-open-in-firefox",
But, your solutions are much nicer 😊
b
And finally, you could approximate a
server.json
-level setting right now by starting your server with a recipe like so
start-site1.boxr
Copy code
config set preferredBrowse=chrome
server start site1
start-site2.boxr
Copy code
config set preferredBrowse=firefox
server start site2
Or, you could even use a
preServerStart
script in your
server.json
to set the
preferredBrowser
before each start, which would work so long as both servers weren't starting at the same time
Amazingly, this works:
Copy code
"openBrowserURL":"C:\\somepathTo\\shortcut-website-open-in-firefox",
Wow, that's is surprising... πŸ€” I wonder if it's opening the actual shortcut in the first browser which then opens the second browser.
c
Wow. So many choices! πŸ˜€
b
lol, lots of ways to skin the cat
But do put in a ticket for something like server.json
Copy code
{
  "name": "site1",
  "browser": "chrome"
}
That's just a few lines of CF code to implement
πŸ‘ 1
I'd just check for that setting prior to defaulting to the default
preferredBrowser
config setting
c
OK. I will add a ticket πŸ‘πŸ»
πŸ™‚ 1
b
@Charles Robertson I had some time to implement this feature tonight, so put in the ticket for you https://ortussolutions.atlassian.net/browse/COMMANDBOX-1554
πŸ‘ 1
This enhancement is now on the bleeding edge of CommandBox
Copy code
server set preferredBrowser=firefox
server open
c
Thanks so much for this. I am looking forward to trying it out. πŸ‘πŸ»