viewflow icon indicating copy to clipboard operation
viewflow copied to clipboard

task views use absolute uri's introducing issues in complex deployments

Open fspegni opened this issue 4 years ago • 0 comments

I noticed that views in viewflow/frontend/views.py invoke the material.frontend.frontend_url function several times.

By default, such function returns an absolute URL (it has parameter absolute=True by default in its definition). This way the URI is built by looking at the value of request.META["HTTP_HOST"].

This is problematic when deploying the django app behind nginx proxies, where the app and the nginx proxy are not on the same machine (e.g. they are physically distributed over a LAN, or on different VMs or containers), in which case the HTTP_HOST meta variable does not correspond to the outside HTTP_HOST used by the user on the address bar of the browser.

My question is: is there a reason why the view should need frontend_url to return an absolute URL? My feeling is that everything works just fine (even better, I would say) if a relative URI is requested, because then the app does not care about the webservers configuration rewriting HTTP_HOST or the port numbers for whatever reason.

For instance:

class AllTaskListView(FlowListMixin(...):
...
    def task_hash(self, task):
        task_url = frontend_url(self.request, self.get_task_url(task), back_link='here', absolute=False)
        return mark_safe('<a href="{}">{}/{}</a>'.format(task_url, task.process.id, task.pk))
    task_hash.short_description = _("#")

and similarly for all views in file viewflow/frontend/views.py (note the absolute=False passed at the frontend_url function).

If you agree that this should be fixed, I can share my changes through a PR.

fspegni avatar Mar 04 '21 11:03 fspegni