Preserve API_URL in response
Hi,
first of all I would like to thank you for your great GUI
Is your feature request related to a problem? Please describe.
I have SaltGUI with API_URL set as /saltgui. So I type http://example.com/saltgui in my browser to log in.
But after logging in I see http://example.com/#minions in my browser.
Describe the solution you'd like
Is it possible to set any parameter to see http://example.com/saltgui/#minions in my browser?
Thank you.
first of all I would like to thank you for your great GUI
thx! these compliments are hereby shared with the founders @oliverdunk and @maerteijn and the many contributors
@ddorosh because SaltGUI is a single page application, there is no actual navigation in the browser. the application updates the address-bar to show the current URL. And that is where it is wrong.
The API_URL is for API calls, it is not for referencing pages. But NAV_URL is. You may have set these 2 to the same value.
I have very little experience in using alternative network setups. But I believe this fix should help:
diff --git a/saltgui/static/scripts/Router.js b/saltgui/static/scripts/Router.js
index 7d950d2c..ae0f4fa3 100644
--- a/saltgui/static/scripts/Router.js
+++ b/saltgui/static/scripts/Router.js
@@ -320,7 +320,7 @@ export class Router {
}
// push history state, so that the address bar holds the correct
// deep-link; and so that we can use the back-button
- let url = "/";
+ let url = config.NAV_URL ? config.NAV_URL : "/";
let sep = "?";
for (const key in pQuery) {
const value = pQuery[key];
that fix is also available in branch saltguiurl.
this github-issue has been converted to a github-PR
can you give it a try?
can you please share the exact configuration from the rest_cherrypy section in the master files, as well as the content of your file config.js? I might be able to test it myself too...
Hi @erwindon
thanks for your fast response.
It work with your changes in /saltgui/static/scripts/Router.js.
When I set NAV_URL as /saltgui/ I see http://example.com/saltgui/#minions in my browser. Exactly what I wanted. Thank you!
But I noticed one more thing. In spite of I have API_URL set to /saltgui my browser sends requests to http://example.com/static instead of http://example.com/saltgui/static

At the same time I have that js from my example at http://example.com/saltgui/static

Considering the proxy server it may cause a problem.
@ddorosh
the includes for the *.js files are hardcoded in file index.html, the only html file that we have. but they are relative to index.html. because these are relative, they should not need API_URL or NAV_URL.
actually, I just made the URLs for the operating system relative too. variable NAV_URL is now only used to produce the updated URL in the address bar. this is a change in the branch from this PR. can you please pull that one in too and retry? please take an extra look at the OS images. before you login, use shift-refresh to make sure that you actually use the updated code. thx!
@erwindon unfortunately it didn't help
Furthermore it "cancelled" previous commit and I see http://example.com/#minions again.
So what I did:
-
undo 8075c4f commit
-
created
saltguifolder inside parent folder for SaltGUI -
moved
staticfolder intosaltguifolder
-
in
index.htmlfile replacedstatic/withsaltgui/static/
So now I have what I want http://example.com/saltgui/#minions in browser address bar and requests from browser to http://example.com/saltgui/static/...

Thank you for your help and your tips!
@ddorosh
Furthermore it "cancelled" previous commit and I see http://example.com/#minions again.
that is odd, as the additional commit was only about the handling of the OS images. did you accidentality switch to another branch?
in theory, there should be no need to move the source code around when you want another base url. you should be able to instruct salt-api/rest_cherrypy to respond to different url prefixes. look in https://docs.saltproject.io/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html for more details. (as you can determine from the wording, I do not have this working yet...)
I'll keep this PR open to investigate further.
@erwindon I cloned it from saltguiurl branch. Hope it was correct.
I tried to play with salt-api/rest_cherrypy parameters, but I didn't get what I need
Kudos, SonarCloud Quality Gate passed! 
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication