在开发者工具network中能够看到字体文件的请求返回的是成功,但是console中输出了以下内容
Font from origin 'http://127.0.0.1:3000' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
这是在服务中koa2-cors的配置
app.use(cors({
origin: function (ctx) {
return '*'
},
exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],
maxAge: 5,
credentials: true,
allowMethods: ['GET', 'POST', 'DELETE'],
allowHeaders: ['Content-Type', 'Authorization', 'Accept'],
})
斯蒂芬大帝
相关分类