Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

307
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda