Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
express app hosted on vercel, only serves specific route

I have this express app in which I have routes file as:

import express from "express";
import { setNews } from "../controller/news-controller.js";
const route = express.Router();

route.get("/", (req, res) => res.send("Home Page Route"));
route.get("/news", setNews);

export default route;

and the news-controller is:

import News from '../modal/news.js';

export const setNews = async (req, res)=>{
    try {
       let data = await News.find({});
       res.status(200).json(data);
    } catch (error) {
        res.status(500).json(error);
    }
}

When I try these two routes locally, it works without any issue.

But when I tried hosting this using vercel. Only / route is served if requested, it responds with "Home Page Route" which is obvious and /news is throwing 404 error

my vercel configuration in vercel.json:

{
  "version": 2,
  "builds": [
    {
      "src": "./index.js",
      "use": "@vercel/node"
    }
  ],
  "routes": [
    {
      "src": "./(.*)",
      "dest": "/"
    }
  ]
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!