Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
Why is my Remote Server not appropriately routing?

I am having trouble getting my VPS server set up appropriately. I copied all the files recursively from my local server to the remote server, but post & get requests to the server are not functioning appropriately (404 not found error). The routing works perfectly on my localhost server, but unfortunately it doesn't on the remote.

Server Code:

// getting datastores
const datastore = require('nedb');
const customerRecordsdb = new datastore("CustomerRecords.db");
customerRecordsdb.loadDatabase();

// importing express
const port        = 3000;
const express     = require('express');
const application = express();
const path        = require('path')
const newPath     = path.join(__dirname + '../../..')

application.listen(port, () => console.log("Listening at " + port));
application.use(express.json( {limit: '1mb'} ));

application.get('/RetrieveCustomerInformation', (request, response) => {
    console.log("SUCCESS!");
    customerRecordsdb.find({}, (error, data) => {
        if (error) {
            response.end();
            return;
        }
        response.json(data);
    })
})

Client Code:

// loading data
let numberRecords = 0;
async function loadClientRecords() {
    const response = await fetch('/RetrieveCustomerInformation');
    const data     = await response.json();

    for (let i = 0; i < data.length; i++) {
        numberRecords++;
        insertNewRecord(data[i]);
    }
}
loadClientRecords()
    .then(response => {
        // was successful
    })
    .catch(error => {
        //console.log(error);
    })

[VPS Page Output] https://i.stack.imgur.com/ghoIa.png (The server is not outputting anything)

[Local Host Page output] https://i.stack.imgur.com/I6mqE.png (The server is outputting "SUCCESS!" on every refresh)

As previously mentioned, I simply copied the directory over to the remote server.

Any help to what the problem could be will be greatly appreciated!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda