前端学习遇到的一些小坑

1.Access to XMLHttpRequest at ‘http://127.0.0.1:8000/delay’ from origin ‘http://localhost:63342’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
请求接口写的xhr.open(‘GET’,‘http://127.0.0.1:8000/delay’);,后台响应应该对应GET或者ALL,直接复制粘贴的post忘记改了,应该是

app.all('/delay',(request,response)=>{
    response.setHeader('Access-Control-Allow-Origin','*');
    response.setHeader('Access-Control-Allow-Headers','*');
    response.send("hello12");

你可能感兴趣的:(前端学习遇到的一些小坑)