无法使用 heroku 后端访问正确的 http 请求 api

Cannot access to correct http request with heroku backend api

我是 运行 heroku 上的 SpringBoot 应用程序,我觉得 Heroku 重定向了来自我的 React 前端的所有请求。 例如,我正在使用 HttpRequestServlet 区域设置来确定我使用哪种语言,甚至 request.getServerName() 来设置 urls 并且对于每个请求它 returns heroku url (xxx.herokuapp.com)。我觉得我的每个请求都被路由器或其他东西重定向了。我怎样才能摆脱它并获得具有正确信息的正确前端请求?

ServletRequest#getServerName 的文档中是这样写的。

Returns the host name of the server to which the request was sent.

不是发送客户端的名称。所以这是预期的行为。

ServletRequest#getLocale 的文档中显示

Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server.

因此,如果您在从客户端发送请求时未在 Accept-Language header 中设置首选区域设置,那么它将 return 服务器当前区域设置。