美文网首页
Node 跨域 Access to XMLHttpRequest

Node 跨域 Access to XMLHttpRequest

作者: visitor009 | 来源:发表于2020-05-25 09:12 被阅读0次

如果跨域用到了put,patch方法,要在响应头设置

// koa
app.use(async (ctx, next) => {
    ctx.set('Access-Control-Allow-Origin','*')
    ctx.set("Access-Control-Allow-Methods", "POST, GET, DELETE,PATCH,PUT"); 
    ctx.response.status = 200 ;
    await next();
});

相关文章

网友评论

      本文标题:Node 跨域 Access to XMLHttpRequest

      本文链接:https://www.haomeiwen.com/subject/gdueahtx.html