请求错误:带有vue cli devserver代理的无效Uri

时间:2019-08-19 18:16:25

标签: javascript vue.js webpack-dev-server jira-rest-api vue-cli

我想从Vue CDN切换到Vue CLI。

之前,我使用jiraClient模块通过API获取信息。

var jiraClient = require('jira-client')

要关闭CORS问题,我只是在以下选项中添加了标志模式:

methods: {
    getLogin: function() {
        this.options = {
          host: '[my company shortcut]-tomcat-jira.[my company name].org/jira',
          apiVersion: 'latest',
          username: this.uname,
          password: this.pword,
          mode: 'cors',
        }
[...]

this.jira = new jiraClient(this.options)

现在使用Vue CLI,我使用代理主机更新了该代码

methods: {
    getLogin: function() {
        this.options = {
          host: 'http://localhost:8080',
          apiVersion: 'latest',
          username: this.uname,
          password: this.pword,
          mode: 'cors',
        }

但是自从我添加了Vue CLI之后,我又遇到了CORS问题。所以我遵循了this tutorial

现在我没有CORS问题。我添加了vue.config.js文件,并在其中添加了以下代码:

module.exports = {
    devServer:{
        proxy: 'http://[my company shortcut]-tomcat-jira.[my Company name].org/jira'
    }
  };

错误是

  

RequestError {名称:“ RequestError”,消息:“错误:无效的URI   “ http:///[http//localhost:8080] ...

似乎代理无法正常工作。 jiraClient对象中的选项不会使用代理URL更新。我错过了一步吗?

编辑:如评论中所述,我删除了“ http://”并添加了端口选项。现在错误更改为404 Connection error: StatusCodeError: 404 - "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET ^...¸

0 个答案:

没有答案