Skip to main content

服务器代理配置归类于 server.proxy 对象下

🌐 Server proxy configurations are grouped under the server.proxy object

在 Strapi 5 中,所有代理配置选项现在都通过 /config/server.js|ts 中的 server.proxy 对象进行配置,无论它们是用于 strapi.fetch 内发出的请求,还是用于 koa 服务器的全局代理代理。

此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 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.

 Is this breaking change affecting plugins?No
 Is this breaking change automatically handled by a codemod?No

重大变更描述

🌐 Breaking change description

在 Strapi v4 中

  • server.globalProxy 用于配置通过 strapi.fetch 的所有请求。
  • server.proxy 用于设置 koa 服务器的 proxy 选项的值。

在 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
  • 如果使用 server.globalProxy,你有两个选择:
    • 将其移动到 server.proxy.global,并注意,它现在不仅适用于 strapi.fetch 请求,还适用于 HTTP/HTTPS 请求,
    • 或者将其移动到 server.proxy.fetch,以保持与 Strapi v4 中完全相同的功能,在那里只有 fetch 被代理。