The Yesod application configures the following:
config/routes
/HomeR GET POST
config/settings.yml
host:"_env:HOST:*4"#any IPv4 host
port: "_env:PORT:3000"
approot: "_env:APPROOT:somedir/"
Accessing "http://localhost:3000/somedir/" in this state does not call the HomeR handler. How do I get the yesod application to move under a specific path?
add
There was a proposal to use reverse proxy.
In Apache's mod_proxy, set it as follows:
Redirect/somedir/somedir/
ProxyPass/somedir/http://localhost:3000/
You can now access HomeR
by accessing http://localhost/somedir/
.However, the URL deployed in the template does not have /somedir/
, which causes the CSS and all links to fail.
For example, write a template similar to the following:
<a href="@{HomeR}">Home</a>
It is deployed to <a href="http://localhost:3000/">Home</a>
.<a href="/">Home</a>
when using ApprootRelative.This will not make the site work.
In order to avoid this, I think it is appropriate to inject somedir
when interpreting config/routes
.However, projects using the stack template do not write that mkYesodData
starts when you build a route by specifying the directory of the application route in the environment variable, not when you read the environment variable.
I'm studying whether to build a route without using mkYesodData
or implement something equivalent to mkYesodData
Approot is used to embed route information in template engines, etc.
Yesod is not the only solution, but in this case,
with reverse proxies such as nginx in between
localhost:3333/somedir->localhost:3000
.
© 2024 OneMinuteCode. All rights reserved.