【发布时间】:2022-04-24 18:51:06
【问题描述】:
我是strapi的新手,我已经下载了strapi v4,作为前端我使用vue.js。
现在我创建了类别,并尝试使用我的 vue 应用程序获取这些类别,但我遇到了 cors 错误。
Access to XMLHttpRequest at 'http://localhost:1337/api/categories' from origin 'http://localhost:8080' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
在documentation 中,我看到我可以覆盖 cors 中间件上的原点,但我不知道如何。
我已经用 resolve 尝试过,然后设置了配置,但这会破坏 cms。
{
resolve: 'strapi::cors',
config: {
origin: 'http://localhost:8080'
}
}
【问题讨论】:
标签: javascript cors strapi