Node 跨域 Access to XMLHttpRequest

2020-05-25  本文已影响0人  visitor009

如果跨域用到了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();
});
上一篇下一篇

猜你喜欢

热点阅读