volto icon indicating copy to clipboard operation
volto copied to clipboard

RAZZLE_API_PATH disables internal proxy, yarn start console output still mentions 'using internal proxy'

Open fredvd opened this issue 2 years ago • 5 comments

Plone 6.0alpha2+ , Python3.9, Volto 14.2

I'm trying to understand the documentation written thttps://docs.voltocms.com/deploying/seamless-mode/ and https://docs.voltocms.com/configuration/internalproxy/ but it didn't click for me until after a lot of experimenting.

I bootstrapped a vanilla Volto 14.2 frontend with Plone 6 and I try to use a different backend port, so not 8080 but for examples 9261. According to the docs seamless mode and the internal proxy is activated by default since Volto 14. This is one of the first configuration tasks an integrator would want to do because not every Plone project (backend) is running on port 8080.

What I didn't notice until all of the experimenting is that setting the RAZZLE_API_PATH env variable the internal RAZZLE proxy is disabled and the browser/frontend directly connects to Plone.

What I should have read first and only was this page https://docs.voltocms.com/configuration/internalproxy/ with RAZZLE_DEV_PROXY_API_PATH=http://localhost:9876/plone , allthough that page only taks about disabling the internal proxy by emptying the env-var.

Razzle is for me a process that runs on the server, the current setup and naming of the variables is prone to misunderstanding. I would propose renaming RAZZLE_API_PATH to FRONTEND_API_PATH . But there also is already API_PATH in the documentation that also seems to do this. 🙄


What set me down the wong path is that if you specify RAZZLE_API_PATH , yarn start console output still contains "Using internal proxy: http://localhost:3000/ -> http://localhost:9261/plone/ "

The only difference in console output with RAZZLE_DEV_PROXY_API_PATH is that is outputs an extra line "Volto is running in SEAMLESS mode" . I'm up for refactoring/updating the documentation now that I (start to) understand how it works, but the variable naming is part of he problem and probably inherited from Razzzle. I haven't looked at the code but I suspect that RAZZLE_API_PATH is copied to API_PATH which disables contacting the internal proxy on the frontend.


Another concept that is easy to mix up is hat the ++api++ path is used for 2 completely different things: a traversal hack for the Plone backend in plone.rest 2.0.0 to always request and deliver application/json without depending on Accept: headers..... but it is also the mountpoint of the internal devproxy.

fredvd avatar Jan 11 '22 13:01 fredvd

https://github.com/plone/volto/pull/3000

sneridagh avatar Jan 22 '22 17:01 sneridagh

Maybe we have to improve too the console messages, which might mislead instead of help.

sneridagh avatar Jan 22 '22 17:01 sneridagh

@fredvd @sneridagh

Is the origin of the Plone api request always from the browser? Regardless of whether RAZZLE_API_PATH or RAZZLE_DEV_PROXY_API_PATH is set? Is there any situation that Volto makes direct requests to the api, excluding of course the situation in which it is used as a proxy (When it is used as a proxy I understand that the origin is from the browser)?

wesleybl avatar Sep 03 '22 14:09 wesleybl

@wesleybl the first request is rendered in SSR (Volto's NodeJS), and it's done in the server to the API backend server.

btw, I improved the situation in #3000 and there was also another PR that enabled the proxy even in production (one year ago approx). So, @fredvd I'd say we can close this one.

sneridagh avatar Sep 03 '22 16:09 sneridagh

@sneridagh in situations where Plone and Volto are on the same network, behind an nginx, is there any configuration, so that these requests that come from the Volto server, are made directly to Plone? This would shorten the way the request would have to go, improving performance.

wesleybl avatar Sep 06 '22 22:09 wesleybl