# 服务器代理配置

> Source: https://strapi.nodejs.cn/cms/migration/v4-to-v5/breaking-changes/server-proxy

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

在 Strapi 5 中，所有代理配置选项都被整合到 `/config/server.js|ts` 中的 `server.proxy` 对象下，取代了 v4 中单独的 `server.globalProxy` 和 `server.proxy` 选项。

🌐 In Strapi 5, all proxy configuration options are consolidated under the `server.proxy` object in `/config/server.js|ts`, replacing separate `server.globalProxy` and `server.proxy` options from v4.

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

此页面是[重大更改数据库](/cms/migration/v4-to-v5/breaking-changes)的一部分，提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the [breaking changes database](/cms/migration/v4-to-v5/breaking-changes) 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}

🌐 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}

🌐 Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

🌐 This section regroups useful notes and procedures about the introduced breaking change.

### 注意 {#notes}

🌐 Notes

关于 `server.proxy` 配置在 Strapi 5 中如何工作的更多信息，请参阅[服务器配置](/cms/configurations/server)文档。

🌐 Additional information about how the `server.proxy` configuration works in Strapi 5 is available in the [server configuration](/cms/configurations/server) documentation.

### 手动迁移 {#manual-migration}

🌐 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 被代理。
