如何修复 vue config js 代理端口错误?

时间:2021-01-24 06:40:17

标签: javascript vue.js proxy axios localhost

我有一个 vue.config.js 文件


module.exports = {
  devServer: {
    proxy: {
      "^/api": {
        target: "http://localhost:3001",
        changeOrigin: true,
secure:false,
      }
    }
  }
};

我的服务器在 3001 上工作,没有问题,我的 get 请求也在工作

    const result = await axios.get(
      "/api/staffs/"
    );
    this.staffs = result.data
this.loading = false

  }, ```


but when I made a post request with, my first request working, I can add one element to the database, but when I make second request there is an error like;

Proxy error: Could not proxy request /api/staffs from localhost:8080 to http://localhost:3001/.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).


here is my post request

async postStaffs() {

  await axios.post("/api/staffs", {
    name: { first:"asdassdeeed", last: "asddseedfdea" },
  });
}, ```

我尝试了 http://127.0.0.1:3001/ 和 pathRewrite,它们没有用。它昨天还在工作,现在我突然收到了这个错误。有谁知道如何解决这个问题?

0 个答案:

没有答案
相关问题