是否可以在Netlify中重写/代理POST请求?

时间:2019-04-18 03:17:24

标签: netlify netlify-cms

在这里Netlify新手。

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

似乎无法重定向POST请求(请参阅W3 documentation for 301/302 redirects-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(类似于this blog post的作者所做的)。当用户向www.domain.com发送POST请求并将其转到Netlify时,此重定向是否也可以正常工作?还是我必须将客户端代码从POST更改为<different_subdomain>.domain.com/legacy_slug并将POST端点迁移到其他子域?

1 个答案:

答案 0 :(得分: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 200 _redirects