是否可以在运行时将 http 请求重定向到不同的服务器?

Is it possible to redirect a http request to different server in runtime?

我打算使用 Amazon Read Replica 复制我的数据库服务器,然后将请求拆分到我的服务器。

每当 READ 请求到达时,API 应该 send/redirect 到副本
当它是 WRITING 请求时,转到另一台服务器。

我正在使用 AdonisJS,我已经能够使用 middleware.
检查请求方法 现在可以更改请求应该去的服务器吗?

我首先想到的是更改 .env 文件,但我认为这不是一个好主意甚至不可能,因为不止一个项目会访问此 API。

您的问题似乎非常具体如何使用 AdonisJS 配置只读副本。

documentation 状态:

AdonisJS supports read/write replicas as first class citizen. You can configure one write database server, along with multiple read servers. All read queries are sent to the read servers in round-robin fashion and write queries are sent to the write server.