在尝试从一个web前端使用HTTP Request请求访问REST服务端时,遇到错误: XMLHttpRequest cannot load http://localhost:8080/ping. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access.
补充:
我服务端java(在eclipse里跑) 传一个图片(服务器路径)给webstorm 然而image访问的是webstorm下的project的资源 而不是Tomcat下的资源。。。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
nginx启动代理 然后配置好跨域 你的所有连接指向nginx服务器 nginx服务器代理你的请求到web service 就是这么easy
调试时修改Access-Control-Allow-Origin值为*,正式上线再调成默认值。
解决跨域的工具比较多,推荐apizza.cc 这个
调试api,写文档,都可以,不用这么麻烦的设置