vue axios post数据报错504

vue文件:

axios.post('/api/nameCheck', {
                name: this.ruleForm2.name
              })
              .then(function (response) {

config/index.js:(target改过本机ip:3000和127.0.0.1:3000均失败)

proxyTable: {
         '/api': {
            target: 'http://localhost:3000/',
            changeOrigin: true,
            // pathRewrite: {
            //   '^/api': ''
            // }
        }
    },

server/app.js:

var users = require('./routes/users');
app.use('/api', users);

routes/users:

router.post('/nameCheck', function(req, res, next) {
    
    return res.send('totally');
});

报错:POST http://localhost:8089/api/nameCheck 504 (Gateway Timeout)
(node后端已打开,用localhost:3000可以正常访问)
[HPM] Error occurred while trying to proxy request /api/nameCheck from localhost:8089 to http://175.8.15x.xx:3000/ (ECONNREFUSED) (https://nodejs.org/api/errors...
(ECONNREFUSED)

(其实昨天还能连接上的,不知道为什么今天就连不上了。。)
请问有具体的解决办法吗?

阅读 14.8k
2 个回答

504 是网关问题 你前端hold不住的 去你的后台

昨天能连上,那么可以从你今天改动的代码去排查

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题