79350245

Date: 2025-01-12 16:20:35
Score: 0.5
Natty:
Report link

Netlify is primarily designed for static sites and serverless functions. You can deploy an Express project, but you cannot deploy Node.js neither run your own Express server.

But Netlify allows you to run your Express project. This is the Netlify starting point, where your Express project is loaded:

netlify/functions/api/js:

import serverless from "serverless-http";
import router from '../../src/routes.js';
import express from 'express';

export const app = express();

app.use('/api/v1', router);

app.use((req, res, next) => {
    res.status(404).json('The requested resource was not found on this server');
});

export const handler = serverless(app);

So if you add that file to your project it should be working.

Deployed result in Netlify: https://test-express-deployment.netlify.app/api/v1/user/test

Repo with fixed code: https://github.com/Borewit/test-netlify-express

Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Borewit