一个奇怪的跨域问题

在学习jfinal的时候,遇到一个奇怪的问题

Access to XMLHttpRequest at 'http://127.0.0.1:8080/izhicheng/login/login' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.

最后发现是因为网页的url用的是localhost,而请求接口的url用的是127.0.0.1,导致的跨域问题,只要两个都用ip或者都用主机名就不会出现问题了

posted @ 2020-10-07 22:12  大家好我叫江某某  阅读(89)  评论(0编辑  收藏  举报