使用 Pyramid - 如何使用挂载点获取 host_url?

With Pyramid - How to get the host_url with the mount point?

我有一个金字塔应用程序,我正在使用 MOD-WSGI 安装在 /myApp 中,但是 request.host_url() returns 主机 URL 没有安装点。现在我通过在 INI 文件中的一个变量中设置挂载点来解决这个问题,我稍后将其连接到 request.host_url() 但是有没有更好的方法来获得带有挂载点的 host_url ?

大概你没有正确设置 WSGIScriptAlias /mountpoint /path/to/my/foo.wsgi 定义 https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIScriptAlias.html - 如果这样做,那么 mod_wsgi 应该在你的环境中正确设置 request.script_name 这将影响 request.host_url 值。