I bought a VPS server and installed a Node app in the root. When I open the IP address where I have Node installed, it takes me to the public folder and everything works as it should. But when I uploaded the same folder to my employer's server, in the path he gave me, the work broke. Now, I have to write the path to the public folder in the URL to display the frontend, but the saddest thing is that now I can't make a request to the backend. I get the same 404 error every time. I don't understand why in the second case the request stops working.
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const PORT = 3000;
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'))
app.post('/submit', (req, res) => {
res.status(200).send({message: 'Everything okay!'})
})
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
})
Frontend
fetch(`http://my[ip]:3000/submit`, {
method: 'POST',
body: JSON.stringify({message: 'Hello, Back!'}),
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.log(err));
I tried to write in Fetch request such path 'https://webapp.monitour.ru/wallstring/crop-image/submit, I tried to write relative path from frontend script to backend script, but then in the response just came the file itself, but not executed '../index.js'..


