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

311
Visualizações
How do I run an API endpoint deployed to Vercel? (not using Next.js)

I've got a bit of a weird set up here with a codebase that I inherited. It's a CRA app deployed to Vercel but doesn't use Next.js.

Problem: I'm not able to call myapp.com/nonce from Postman or access it in my browser to see the JSON response. There's some configuration stuff that's not quite right, just trying to figure out what that is. Would love any help here!

I have a file structure that looks like this:

Project (create-react-app)
   src
     bunch of React code
   server
     index.js
     package.json
   package.json

(It's not using next.js. If it were, I'd just use the /pages/api/* files)

In my top-level package.json, I have:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build && cd server && npm install && npm run start",
}

and in my /server/package.json I have just a simple start command: node index.js

My server/index.js file:

const path = require('path');
const express = require("express");
const PORT = process.env.PORT || 3001;
const app = express();

app.use(express.static(path.resolve(__dirname, '../MyProject/build')));


app.get('/nonce', async (req, res) => {
  const { address } = req.query;
  const quantity = snapshot[address];

  return res.json({ quantity, address }); // for testing 
})

Edit:

With this as-is, my build phase never actually completes.. It runs a server at 3001 and that's the last log of the Build log

> MyProject-server@0.1.0 start /vercel/path0/server
> node index.js
Server listening on 3001
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