【发布时间】:2021-06-15 15:01:40
【问题描述】:
尝试将 API 与我使用 Nuxt.js 构建并使用 AWS Amplify 托管的应用程序集成。我添加了一个代理,它在本地运行良好,但它在 AWS 服务器中为 POST 方法返回 405 MethodNotAllowed。
对于代理,我进行了如下更改以重写路径:
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 错误。我错过了什么?
【问题讨论】:
标签: amazon-web-services vue.js proxy nuxt.js aws-amplify