Skip to content

Server side language headers #1980

@YanaDePauw

Description

@YanaDePauw

Describe the bug

Currently, the server side rendering does not take into account the languages provided by browser whereas the client side rendering will take this into account when doing a request to the backend.
This is visible in the "Accept-Language" headers being different in requests that come from the server side rendering and the ones coming from client side rendering.

This can cause discrepancies between pages that depend on these languages being loaded server side and client side.

To Reproduce

Reproducing this issue requires inspecting the "Accept-Language" header of server side calls which aren't visible in the network tab of a browser.
The easiest way to achieve this is to hook a backend you can debug to the angular application and then debug the incoming calls and compare the headers from the server side calls and the client side calls.

An example on how to do this is the following:

  1. Set up a backend instance and hook this to the front end
  2. Run the front end in production mode
  3. Make sure your browser languages and the repository language are different.
  4. Set a breakpoint in the SiteRestRepository on the first line of the findOne method.
  5. In the angular app, open the network tab and navigate to the repository home page.
  6. When the code initially stops at the breakpoint, check the user-agent of the request by using the following command:
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("user-agent");
  7. Verify this contains node.js in the value.
  8. Retrieve the "Accept-Language" header by running:
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("Accept-Language");
  9. Verify that this list contains the main UI language but NOT your browser languages
  10. Continue the code, and keep continuing until you requests start showing up in the network tab. This means that client side calls will start coming in into the back end.
  11. When the code stops again at the breakpoint, retrieve the user agent again:
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("user-agent");
  12. Verify that it does NOT contain node.js in the value.
  13. Retrieve the "Accept-Language" header by running:
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("Accept-Language");
  14. Verify that this list contains both the UI language and your browser languages.

Expected behavior

The languages in the Accept-Language header for requests to the backend should be the same for client side and server side rendering.

Related work

A PR has been created for this issue: #1981

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions