真的是一个字:日了X了,搞了一天,尝试了各种办法,都无法解决,诡异的是两个vue项目接同一个Lravel后台,一个跨域,一个正常。最后终于在这大哥的文章里解决了。 传送门https://yunan.blog.csdn.net/article/details/104761517?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-1.fixedcolumn&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-1.fixedcolumn /* * 跨域,正式版去掉 * */ header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, HEAD, PUT, POST, DELETE, PATCH, OPTIONS'); header('Access-Control-Allow-Credentials: ture'); header('Access-Control-Max-Age: 86400'); header('Access-Control-Allow-Headers: Content-Type, Authorization, Origin, Accept, X-Requested-With'); header('Content-Type: application/json'); $method = $_SERVER['REQUEST_METHOD']; if ($method == "OPTIONS") { header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method,Access-Control-Request-Headers, Authorization"); header("HTTP/1.1 200 OK"); die(); }