trailsjs / trails

:evergreen_tree: Modern Web Application Framework for Node.js.
http://trailsjs.io
Other
1.67k stars 70 forks source link

Have a way to retrieve app url #118

Open jaumard opened 8 years ago

jaumard commented 8 years ago

Trailpacks sometimes need to have access to the app url (for email url or url callbacks for example).

Maybe we can simply add a config.main.appUrl who is by default set to 'http://' + config.web.host + ':' + config.web.port and users can override it under main.js.

Like this trailpacks who need app url can always use config.main.appUrl instead of each one try to guess what it is...

related to https://github.com/trailsjs/trails/issues/104

tjwebb commented 8 years ago

Yea I think we could set this in config.web. There's no "standard" right now, but I think baseUrl makes sense. Various trailpacks already use hostname and port in config.web

jaumard commented 8 years ago

Yeah I think it's better to avoid using host and port directly because how trailpack can detect SSL option ? Because host normally doesn't contains http(s). It will depends of the web server... If there a config.web.baseUrl user can set it with http/https if they want to.

Like this no problems with Trailpack that don't detect baseUrl correctly. Trails (or trailpack-core or each webserver trailpack ?) should set config.web.baseUrl to 'http://' + config.web.host + ':' + config.web.port by default.