2

Netlify noob 在这里。

我目前正在迁移旧的 Ruby on Rails 应用程序以将 Netlify 用于静态站点。我们希望在旧代码库中保留一些遗留静态页面,这些遗留静态页面向我们的服务器发出 POST 请求。

似乎无法重定向 POST 请求(请参阅W3 文档以了解 301/302 重定向- If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.),但我想知道当您代理/重写 URL 时这是否有所不同。

目前,我们通过 Netlify 的 splat 重定向重写用户的请求www.domain.com/legacy_slug(类似于这篇博文的作者所做的)。当用户向 POST 请求发送www.domain.com到 Netlify 时,此重定向是否也可以正常工作?或者我是否必须将客户端的代码更改为 POST<different_subdomain>.domain.com/legacy_slug并将 POST 端点迁移到不同的子域?

4

1 回答 1

1

代理(https://www.netlify.com/docs/redirects/#proxying)接受 POST、重定向(https://www.netlify.com/docs/redirects/#basic-redirects)或重写(HTTP 200从一到另一个的路径,都在 netlify 托管的站点上),没有。

一种微妙的区别。所以 - 我会将 POST 发送到其他路径(而不是其他域 - 只是 /place-we-post-to 在您的 Netlify 站点上,并使用代理重定向来访问您的远程服务(/place-we-post-to https://legacybackend.com 200in _redirects

于 2019-04-18T17:17:03.567 回答