Skip to content

前端展示报错,找不到文章 #20

@brucewu10

Description

@brucewu10

我按照楼主的步骤,在本地启动 后端及 前端

  1. 本机部署及启动后端工程,浏览器访问 http://localhost:8080/tumo 成功;

  2. 本机部署前端,http://localhost:9528/ 可以打开,但是访问 文章列表失败;
    经过排查,发现问题是跨域访问导致,在vue.config.js 的跨域配置少了部分内容:

    proxy: {
    '/api': {
    target: 'http://localhost:8080/',
    ws: true,

     //少了下面部分,导致加了/api 后,无法找到对应的后台接口
     changeOrigin: true,
     pathRewrite: {
      // ^代表字符串开头,实际发送请求时,会把请求开头的/demo删除
      // 因为/demo并不是请求的一部分,只是个代理的标识
         "^/api": ""
     }
    

    }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions