'vue: message: Network Error, name: AxiosError

It works well on the local host, but when i upload it to the server and run it, an error occurs.

const corsOptions = {
  origin: 'http://localhost:3000',
  credentials: true,
  
};

app.use(cors(corsOptions));

app.get('/getItem', (req, res) => {
  console.log("home");
  conn.getItem(req, res);
});
app.use(express.json());
app.use('/home', express.static("./public"));
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/', express.static("./public"));
app.post('/get', (req, res) => {
  conn.user(req, res);
});

app.get('/home', (req, res) => {
  res.sendFile(path.join(__dirname + '/public/index.html'));
});


app.listen(3000, function (req, res) {
  console.log('Server started to listen at 3000');
});

errormessage

How can I get response from http url by axios (or request)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source