This is a very simple question: how to run a Yesod application that can handle multiple hosts at once?
The default Yesod setting can handle incoming connections from any host, but all URLs are displayed with approot
added to them. Overriding joinPath
in a Yesod instance declaration would be possible if there was a way to store the current domain so that it was available for this function, but it wasn’t.
The method described on this wiki page is very hacky because it forces the routes to accept an additional domain
parameter (since I don’t have a static set of domains to map to). For practical purposes (because I have many routes, some of which are domain-independent), it would be better to have a solution that would leave the routes intact, since it is possible to get the host name from the WAI request information inside the handler function.
I use things that require absolute URLs (e.g. email, RSS, XML API), so approot _ = ""
not an option.
I do not know and cannot know all the host names that must be supported at compile time.
So, how do I display the URLs so that they use the host name of the incoming request and not the approot
variable?
source share