Documentation Error?
Added by lm at over 7 years ago
The documentation for Wt::WApplication::enableInternalPaths()
says, "Sets the message for the user when the application was ." which is surely an oversight.
I came across this researching this problem:
... tl;dr: How do I get Wt::WApplication::makeAbsoluteUrl
to return the right thing based on my --deploy-path
?
When I launch my application with
./app --deploy-path="/app" --docroot '.;css' --http-address 0.0.0.0 --http-port 9090
everything seems to work well. The application shows up in a browser when I go to http://localhost:9090/app
, CSS works (resources are at ./resources/
), etc. (equested CSS files have log entries like
"GET /resources/themes/default/wt.css HTTP/1.1" 200 20259
In my application, I added the following code:
INFO("make absolute url= %s", makeAbsoluteUrl("new_group").c_str());
INFO("make absolute url= %s", makeAbsoluteUrl("/new_group").c_str());
INFO("make absolute url= %s", makeAbsoluteUrl("new_group/").c_str());
INFO("make absolute url= %s", makeAbsoluteUrl("/new_group/").c_str());
This is what was returned:
[7601] info app:41 -- make absolute url= http://localhost:9090/new_group/
[7601] info app:42 -- make absolute url= http://localhost:9090/new_group
[7601] info app:43 -- make absolute url= http://localhost:9090/new_group
[7601] info app:44 -- make absolute url= http://localhost:9090/new_group/
This makes sense since WebSession::makeAbsoluteUrl
parses the --deploy-path
up to the last '/', but I hoped at least one of them would return http://localhost:9090/app/new_group
(or perhaps http://localhost:9090/app/new_group/
). I changed my run script to
./app --deploy-path="/app/" --docroot '.;css' --http-address 0.0.0.0 --http-port 9090
and now the output of the above code is
[17169] info app:41 -- make absolute url= http://localhost:9090/app/new_group/
[17169] info app:42 -- make absolute url= http://localhost:9090/new_group
[17169] info app:43 -- make absolute url= http://localhost:9090/app/new_group
[17169] info app:44 -- make absolute url= http://localhost:9090/new_group/
Which is much better. The only problem is that static resources aren't being accessed (the login page shows up with no CSS, etc.). (The log statements now look like "GET /app/resources/themes/default/wt.css HTTP/1.1" 200 2242
.)
I tried changing to
--docroot './app;css'@ and @--docroot './app/;css'
and I tried moving ./resources
to ./app/resources
, and a few other things, but nothing worked.
I checked the examples and the only time I see --deploy-path
set to something besides "/" is in wt/examples/codeview/README.md
, where it says --deploy-path=/code
(no terminating slash). What's the right incantation to get Wt::WApplication::makeAbsoluteUrl
to do right, and static resources accessed properly?
Replies (1)
RE: Documentation Error? - Added by lm at almost 7 years ago
I'm pretty sure there are bugs and design errors around this --deploy-path
and --docroot
business. For instance:
I want to serve my wt app at http://localhost/app
, and serve the assets at, for instance, http://localhost/app/css/styles.css
and http://localhost/app/js/myfile.js
I can't figure out how to do it.