vue.js - 使用 Vue/Axios 调用访问 Jenkins api 的问题
问题描述
我尝试使用 axios 从我的 Vue js 代码库/环境到 Jenkins API 进行 get 调用,但我无法这样做。
我已经阅读了我可以但无法解决这个特定问题的所有资源。我什至创建了一个 .htaccess 文件来查看它是否有帮助但没有用。我用完了所有选项,所以我来这里寻求帮助。
下面是我在 App.vue 文件中使用的 axios 代码。
axios.get(
*URL to access Jenkins that is currently running on a tomcat server*,
{
headers: {
"jenkins-crumb": "* Some numbers and letters*",
},
auth: {
username: "*obvious username*",
password: "*obvious password*"
},
withCredentials: true,
crossdomain: true
}
)
.then(response => (this.info= response)).catch(error => (console.log(error)));
控制台日志输出:
从源“ http://localhost:8080 ”访问“url”处的 XMLHttpRequest已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:不存在“Access-Control-Allow-Origin”标头在请求的资源上。
网络输出:
一般
请求 URL:URL
请求方法:OPTIONS
状态代码:403
远程地址:localhost:8080
推荐人策略:no-referrer-when-downgrade请求
标头 显示临时标头
Access-Control-Request-Headers: authentication,jenkins-crumb
Access-Control-Request-Method: GET
Origin: http://localhost:8080
Referer: http://localhost:8080/
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, 像 Gecko) Chrome/77.0.3865.90 Safari/537.36
请帮忙!
解决方案
推荐阅读
- python - 当我对手动创建的 Dataframe 执行操作时出现 Pyspark 错误
- macos - 重置 Neo4j 浏览器样式
- javascript - 我似乎无法为每个块获得单独的 ID
- python - 在 OpenCV 中保存灰度视频?
- django-oscar - Django Oscar - 为产品属性添加选项
- sql-server - 将大查询结果传递给过程
- include - Ansible:仅当服务器不在组中时才包含任务
- java - 在 Java 中查找素数
- angular - 如何使数据在 Angular 2 的详细页面中可见?
- sql - 对表 SQL 中的特定值进行计数和求和