跨城问题
遇到个很奇怪的问题,不知道是浏览器的问题,还是我的问题
有点意思的是,我用本地的127.0.0.1:8080,请求 localhost 端口的接口就不跨域,但是
我用127.0.0.1:8080,就报跨域,后面经过几次测试用 localhost 直接请求域名,居然得行了。没有搞懂
//跨域一定要设置好,请求允许的header头, 'Access-Control-Allow-Origin' => '*', 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, PATCH, DELETE', 'Access-Control-Allow-Headers' => 'Access-Control-Allow-Headers,Origin,Accept,accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Authorization,authorization,Access-Control-Request-Headers,X-CSRF-TOKEN' //千遍一律,一定要注意:
Authorization,x-token,这种自定义的一定要写进去