使用 Nuxt.js 代理的 POST 方法中的 AWS Amplify 405 MethodNotAllowed 错误

AWS Amplify 405 MethodNotAllowed error in POST method with Nuxt.js Proxy

尝试将 API 与我使用 Nuxt.js 构建并由 AWS Amplify 托管的应用程序集成。我添加了一个代理,它在本地完美运行,但它在 AWS 服务器中 returns 405 MethodNotAllowed 用于 POST 方法。

对于代理,我做了如下更改以重写路径:

axios: {
 proxy: true
},
proxy: {
 '/lead/': { target: 'https://api.apidomain.org/v2', pathRewrite: { '^/lead/': '' }, 
  changeOrigin: true }
},

我已经阅读了 Amplify documentation,我们可以在其中更新重定向,所以我已经尝试了

[
{
    "source": "/<*>",
    "target": "/index.html",
    "status": "404-200",
    "condition": null
},
{
    "source": "</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>",
    "target": "/index.html",
    "status": "200",
    "condition": null
},
{
    "source": "/lead/<*>",
    "target": "https://api.apidomain.org/v2/<*>",
    "status": "200",
    "condition": null
}
]

前两条规则是默认规则,我添加了第三条规则,但仍然出现 405 MethodNotAllowed 错误。我错过了什么?

放大重定向从列表顶部向下执行。这已通过重新排序规则得到解决。

[
{
    "source": "/lead/<*>",
    "target": "https://api.apidomain.org/v2/<*>",
    "status": "200",
    "condition": null
},
{
    "source": "</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json)$)([^.]+$)/>",
    "target": "/index.html",
    "status": "200",
    "condition": null
}
]