问题:VUE工程配置proxyTable但是没起作用
在/config/index.js中
proxyTable: {
'/api': {
target: 'http://localhost:8443',
changeOrigin: true,
pathRewrite: {
'^/api': 'api'
}
}
}
target ,pathRewrite都没有起作用
原因分析:
原因是在/main.js中
axios.defaults.baseURL = ‘http://localhost:8443/api’
这样在axios请求
this.$axios
.post('/login', {
username: this.loginForm.username,
password: this.loginForm.password
})
而且在后端增加的@CrossOrigin支持了跨域前端仍可以正常调用,在/config/index.js中proxyTable因为从http://开始匹配,找不到‘api’,代理没有起作用
@CrossOrigin
@RestController
public class LoginController {
@Autowired
UserService userService;
@PostMapping("/api/login")
public Result login(@RequestBody User reque