huridocs / uwazi

Uwazi is a web-based, open-source solution for building and sharing document collections
http://www.uwazi.io
MIT License
227 stars 81 forks source link

Request headers in SSR for new routes #6041

Open Zasa-san opened 12 months ago

Zasa-san commented 12 months ago

Describe the bug After the upgrade to Node 18 an issue appeared with the headers that are set when configuring multitenants. https://uwazi.readthedocs.io/en/latest/sysadmin-docs/multi-tenant.html#serving-the-web-app In the setup of the reverse proxy we set the Connection header to 'upgrade', among other things.

Node 18's fetch rejects this Connection header. This was causing an error when reloading certain routes since we server side render them, and the requests are now using fetch from Node 18.

This error would only occur on the V2 routes. This is because previously, for V1 routes, we cleared all the headers when doing SSR: https://github.com/huridocs/uwazi/blob/b85403abcdaaef32fc0b71b782eb66143a33eed2/app/react/App/RouteHandler.js#L59-L63

For the newer routes we are passing all the headers that come from the request, this includes this Connection one.

We need to make a decisions regarding how we want to construct the headers for the new routes. For now we are simply clearing the Connection header when doing SSR. https://github.com/huridocs/uwazi/blob/b85403abcdaaef32fc0b71b782eb66143a33eed2/app/react/entry-server.tsx#L245-L255

This change fixes the bug, but we should still find a concise way of setting up headers for SSR on V2 routes.

Zasa-san commented 11 months ago

It would also be worthwhile to configure our e2e to run on a setup similar to a production environment in terms of having a reverse proxy.

txau commented 11 months ago

@Zasa-san while that is the right solution, I think we have had problems of integration with the load balancer 2 times in our whole history. This could have well been detected on staging, which unfortunately didn't happen. So I have the dilemma of investing into this or not.

Zasa-san commented 11 months ago

@Zasa-san while that is the right solution, I think we have had problems of integration with the load balancer 2 times in our whole history. This could have well been detected on staging, which unfortunately didn't happen. So I have the dilemma of investing into this or not.

Do you mean the whole issue or the e2e part?

Maybe when we can work on how we construct the headers when we continue with #5938. I think this can be a concern of the client API layer.

The e2e part can be a separate issue that we work when time permits.

txau commented 11 months ago

I mean the load balancer in the CI part.