服务器代理配置分组在 server.proxy 对象下
¥Server proxy configurations are grouped under the server.proxy object
在 Strapi 5 中,所有代理配置选项现在都通过 /config/server.js|ts 中的 server.proxy 对象进行配置,无论它们是针对 strapi.fetch 内发出的请求还是针对 koa 服务器的全局代理代理。
¥In Strapi 5, all proxy configuration options are now configured through the server.proxy object in /config/server.js|ts, whether they are for requests made within strapi.fetch or for the global proxy agent for the koa server.
此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。
¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.
| 🔌 此重大更改是否会影响插件? | 否 |
|---|
| 🤖 此重大更改是否由 codemod 自动处理? | 否 |
|---|
重大更改描述
¥Breaking change description
在 Strapi v4 中
¥In Strapi v4
-
server.globalProxy用于通过strapi.fetch配置所有请求。¥
server.globalProxyis used to configure all requests throughstrapi.fetch. -
server.proxy用于设置 koa 服务器的proxy选项的值。¥
server.proxyis used to set the value of koa server’sproxyoption.
在 Strapi 5 中
¥In Strapi 5
所有配置选项都分组在 server.proxy 对象下。
¥All configuration options are grouped under the server.proxy object.
迁移
¥Migration
本节重新组合了有关引入的重大更改的有用说明和程序。
¥This section regroups useful notes and procedures about the introduced breaking change.
注意
¥Notes
有关 server.proxy 配置在 Strapi 5 中的工作原理的更多信息,请参阅 服务器配置 文档。
¥Additional information about how the server.proxy configuration works in Strapi 5 is available in the server configuration documentation.
手动迁移
¥Manual migration
用户需要手动更新代码:
¥Users will need to manually update the code:
-
如果使用
server.proxy,则需要移至server.proxy.koa。¥If
server.proxyis used, it needs to move toserver.proxy.koa. -
如果使用
server.globalProxy,你有 2 个选择:¥If
server.globalProxyis used, you have 2 choices:-
将其移动到
server.proxy.global,并注意它现在除了strapi.fetch请求之外还适用于 HTTP/HTTPS 请求,¥move it to
server.proxy.globaland be aware that it will now work for HTTP/HTTPS requests in addition tostrapi.fetchrequests, -
或将其移动到
server.proxy.fetch以保持与 Strapi v4 中完全相同的功能,其中只有获取是代理的。¥or move it to
server.proxy.fetchto keep the exact same functionality as in Strapi v4, where only fetch was proxied.
-