【发布时间】:2020-01-08 10:45:48
【问题描述】:
我在 Nuxt 中使用 API,这是我的 nuxt.config.js 以允许请求:
axios: {
prefix: '/api/',
proxy: true,
},
proxy: {
'/api/': {
target: process.env.API_URL || 'http://localhost:1337',
pathRewrite: {
'^/api/': '/',
}
},
}
在我的应用程序的特定页面上,我需要从另一个域向另一个 API 发送请求。我在这个 Vue 组件中使用 axios 直接:
axios.post('mysite.com/widget.rest')
作为响应,我收到 CORS 错误。我可以在我的配置中允许多个 API 吗?
【问题讨论】: